本文整理汇总了Python中weakref.proxy函数的典型用法代码示例。如果您正苦于以下问题:Python proxy函数的具体用法?Python proxy怎么用?Python proxy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了proxy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start
def start(self):
import BattleReplay
replayCtrl = BattleReplay.g_replayCtrl
if isEventBattle():
replayCtrl.enableAutoRecordingBattles(0)
isReplayRecording = replayCtrl.isRecording
isReplayPlaying = replayCtrl.isPlaying
self.__arenaDP = ArenaDataProvider()
self.__ctx.start(self.__arenaDP)
self.__ammoCtrl = consumables.createAmmoCtrl(isReplayPlaying, isReplayRecording)
self.__equipmentsCtrl = consumables.createEquipmentCtrl(isReplayPlaying)
self.__optDevicesCtrl = consumables.createOptDevicesCtrl()
self.__vehicleStateCtrl = vehicle_state_ctrl.createCtrl(isReplayRecording)
self.__chatCommands = ChatCommandsController()
self.__arenaLoadCtrl = ArenaLoadController()
self.__drrScaleCtrl = DRRScaleController()
self.__respawnsCtrl = RespawnsController()
self.__notificationsCtrl = NotificationsController()
self.__repairCtrl = RepairController()
self.__arenaListeners = ListenersCollection()
self.__arenaListeners.addController(weakref.proxy(self.__ctx), self.__arenaLoadCtrl)
self.__arenaListeners.addController(weakref.proxy(self.__ctx), self.__respawnsCtrl)
self.__arenaListeners.start(arenaDP=self.__arenaDP)
self.__feedback = createFeedbackAdaptor(isReplayPlaying)
self.__feedback.start(self.__arenaDP)
self.__requestsCtrl = AvatarRequestsController()
开发者ID:krzcho,项目名称:WOTDecompiled,代码行数:26,代码来源:battlesessionprovider.py
示例2: mempin
def mempin(self, owner, pointer, size, mapped=False):
self.trashing.service()
if isinstance(pointer, (int, long)):
pointer = c_void_p(pointer)
if mapped and not self.device.CAN_MAP_HOST_MEMORY:
raise CudaDriverError("%s cannot map host memory" % self.device)
# possible flags are "portable" (between context)
# and "device-map" (map host memory to device thus no need
# for memory transfer).
flags = 0
if mapped:
flags |= enums.CU_MEMHOSTREGISTER_DEVICEMAP
driver.cuMemHostRegister(pointer, size, flags)
if mapped:
_mapped_finalizer = _make_mem_finalizer(driver.cuMemHostUnregister)
finalizer = _mapped_finalizer(self, pointer)
mem = MappedMemory(weakref.proxy(self), owner, pointer, size,
finalizer=finalizer)
self.allocations[mem.handle.value] = mem
return mem.own()
else:
mem = PinnedMemory(weakref.proxy(self), owner, pointer, size,
finalizer=_pinned_finalizer(self.trashing,
pointer))
return mem
开发者ID:PierreBizouard,项目名称:numba,代码行数:31,代码来源:driver.py
示例3: __init__
def __init__(self, plugin, callback, userdata, is_unload):
self.is_unload = is_unload
self.plugin = weakref.proxy(plugin)
self.callback = callback
self.userdata = userdata
self.hexchat_hook = None
self.handle = ffi.new_handle(weakref.proxy(self))
开发者ID:hexchat,项目名称:hexchat,代码行数:7,代码来源:python.py
示例4: __init__
def __init__(self, sess, gpcs, objectID, pa, refID):
try:
self.__dict__['session'] = weakref.proxy(sess)
except TypeError:
self.__dict__['session'] = sess
sys.exc_clear()
self.__dict__['objectID'] = objectID
self.__dict__['sessionCheck'] = None
self.__dict__['persistantObjectID'] = objectID
self.__dict__['gpcs'] = weakref.proxy(gpcs)
self.__dict__['__publicattributes__'] = pa
self.__dict__['objectChangeHandlers'] = weakref.WeakKeyDictionary({})
mask = sess.Masquerade()
try:
self.__dict__['clisid'] = gpcs.machoNet.GetClientSessionID()
finally:
mask.UnMask()
if objectID[0] == 'C':
self.__dict__['blocking'] = 0
cid, oid = objectID.split(':')
cid = cid.split('=')[1]
self.__dict__['destination'] = macho.MachoAddress(clientID=long(cid))
else:
self.__dict__['blocking'] = 1
nid, oid = objectID.split(':')
nid = nid.split('=')[1]
self.__dict__['destination'] = macho.MachoAddress(nodeID=long(nid))
self.__dict__['deleted'] = 0
sess.RegisterMachoObjectConnection(objectID, self, refID)
开发者ID:Pluckyduck,项目名称:eve,代码行数:31,代码来源:ObjectCallGPCS.py
示例5: __init__
def __init__(self, machine, communicator=None, **kwargs):
from candelabra.topology.machine import MachineNode
assert isinstance(machine, MachineNode)
assert isinstance(communicator, Communicator)
self.machine = proxy(machine)
self.communicator = proxy(communicator) if communicator else proxy(machine.communicator)
开发者ID:inercia,项目名称:candelabra,代码行数:7,代码来源:base.py
示例6: process_ConnectionBind
def process_ConnectionBind(self, head, payload):
log.info("%r process bind" % self)
try:
payload = json.loads(payload.decode())
connection_id = payload.get('connection_id')
self.connection_id = connection_id
relay_session = self.server.allocation.relay_sessions.get(connection_id)
data_session = self.server.allocation.data_sessions.get(connection_id)
if connection_id and relay_session and data_session is None:
relay_session.set_data_session(weakref.proxy(self))
self.set_relay_session(weakref.proxy(relay_session))
self.server.allocation.data_sessions[connection_id] = self
rsp = {
'code': 200
}
log.info("bind ok")
else:
rsp = {
'code': 400
}
self.send_response(head, json.dumps(rsp).encode())
except Exception as e:
log.error(e)
开发者ID:ryanking8215,项目名称:my_turn,代码行数:25,代码来源:server.py
示例7: test_basic_proxy
def test_basic_proxy(self):
o = C()
self.check_proxy(o, weakref.proxy(o))
L = UserList.UserList()
p = weakref.proxy(L)
self.failIf(p, "proxy for empty UserList should be false")
p.append(12)
self.assertEqual(len(L), 1)
self.failUnless(p, "proxy for non-empty UserList should be true")
p[:] = [2, 3]
self.assertEqual(len(L), 2)
self.assertEqual(len(p), 2)
self.failUnless(3 in p,
"proxy didn't support __contains__() properly")
p[1] = 5
self.assertEqual(L[1], 5)
self.assertEqual(p[1], 5)
L2 = UserList.UserList(L)
p2 = weakref.proxy(L2)
self.assertEqual(p, p2)
## self.assertEqual(repr(L2), repr(p2))
L3 = UserList.UserList(range(10))
p3 = weakref.proxy(L3)
self.assertEqual(L3[:], p3[:])
self.assertEqual(L3[5:], p3[5:])
self.assertEqual(L3[:5], p3[:5])
self.assertEqual(L3[2:5], p3[2:5])
开发者ID:alkorzt,项目名称:pypy,代码行数:28,代码来源:test_weakref.py
示例8: onSessionStart
def onSessionStart(self, hdrs):
self.__init__()
self.loadVoiceLib()
self.mailbox = IMAP4_Mailbox(getSessionParam(hdrs, "Mailbox-URL"))
debug("***** Mailbox Url: ******\n" + str(self.mailbox.url))
self.new_msgs = self.loadMsgList("UNSEEN")
self.saved_msgs = self.loadMsgList("SEEN")
if (len(self.new_msgs) == 0) and (len(self.saved_msgs) == 0):
self.enqueue(self.voice_lib["no_msg"], None)
self.enqueue(self.voice_lib["bye"], None)
self.exit = True
return
self.enqueue(self.voice_lib["you_have"], None)
if len(self.new_msgs) > 0:
self.enqueue(self.voice_lib["new_msg"], None)
self.msg_list = weakref.proxy(self.new_msgs)
self.cur_list = weakref.ref(self.new_msgs)
if len(self.saved_msgs) > 0:
self.enqueue(self.voice_lib["and"], None)
self.enqueue(self.voice_lib["saved_msg"], None)
else:
self.enqueue(self.voice_lib["saved_msg"], None)
self.msg_list = weakref.proxy(self.saved_msgs)
self.cur_list = weakref.ref(self.saved_msgs)
self.enqueueCurMsg()
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:35,代码来源:mailbox_query.py
示例9: __init__
def __init__(self, form, parent):
try:
self.form = weakref.proxy(form)
except TypeError:
self.form = form
try:
self.parent = weakref.proxy(parent)
except TypeError:
self.parent = parent
self._commands = {'abort': basic.abort,
'action': basic.action,
'brakes': basic.brakes,
'connect': basic.connect,
'disconnect': basic.disconnect,
'fbw': basic.fbw,
'gear': basic.gear,
'haiku': basic.haiku,
'help': self.helps,
'lights': basic.lights,
'log': logs.logs,
'rate': basic.rate,
'rcs': basic.rcs,
'sas': basic.sas,
'sa': mechjeb.smartass,
'send': basic.send,
'stage': basic.stage,
'text': basic.text,
'telemetry': basic.telemetry,
'throttle': basic.throttle,
'quit': basic.quits,
'exit': basic.quits, # overlaps with quit
}
开发者ID:SavinaRoja,项目名称:Kerminal,代码行数:34,代码来源:__init__.py
示例10: join
def join(self, drone):
'Add this drone to our ring'
# Make sure he's not already in our ring according to our 'database'
if self.members.has_key(drone.designation):
print self.members
raise ValueError("Drone %s is already a member of this ring [%s]"
% (drone.designation, self.name))
# Insert this drone into our 'database', and us into the drone's
self.members[drone.designation] = weakref.proxy(drone)
drone.ringmemberships[self.name] = weakref.proxy(self)
partners = self._findringpartners(drone) # Also adds drone to memberlist
#print >>sys.stderr,'Adding drone %s to talk to partners'%drone.designation, partners
if partners == None: return
if len(self.memberlist) == 2:
drone.start_heartbeat(self, partners[0])
partners[0].start_heartbeat(self, drone)
return
elif len(self.memberlist) > 3:
partners[0].stop_heartbeat(self, partners[1])
partners[1].stop_heartbeat(self, partners[0])
drone.start_heartbeat(self, partners[0], partners[1])
partners[0].start_heartbeat(self, drone)
partners[1].start_heartbeat(self, drone)
开发者ID:Alan-R,项目名称:assimilation-persistent-events,代码行数:25,代码来源:obsolete_cma.py
示例11: setSetting
def setSetting(solver, value):
app = solver.get_app()
try:
root = solver.get_root_parent()
exec root._name + ' = root'
if len(value[1].split()) != 0:
a = eval(value[1])
if isinstance(a, PyModel):
solver._model = weakref.proxy(a)
else:
dialog.message(app, 'Model should be PyModel', 'Error')
solver._model = None
if len(value[2].split()) != 0:
b = eval(value[2])
if isinstance(b, PySol):
solver._sol = weakref.proxy(b)
else:
dialog.message(app, 'Sol should be PySol', 'Error')
solver._sol = None
if len(value[3].split()) != 0:
b = eval(value[3])
if isinstance(b, PyParam):
solver._param = weakref.proxy(b)
else:
dialog.message(app, 'Parameter should be PyParam', 'Error')
solver._param = None
except Exception:
logging.exception("Solver Setting Failed")
开发者ID:piScope,项目名称:piScope,代码行数:28,代码来源:py_solver.py
示例12: post_init
def post_init(self):
""" Finalizes client initialization by querying API root info
"""
log.debug("Getting root resources")
response = self.nc.request(self.api_root)
# obtain api info info
self.root = Root.from_response(response, self.root_url)
# instantiating handlers
self._projects = ProjectHandle(
weakref.proxy(self), self.nc, root_url=self.root_url,
projects_href=self.root.get_href_by_name(u"projects"),)
self._project_chroots = ProjectChrootHandle(
weakref.proxy(self), self.nc, root_url=self.root_url)
self._builds = BuildHandle(
weakref.proxy(self), self.nc, root_url=self.root_url,
builds_href=self.root.get_href_by_name(u"builds"),)
self._build_tasks = BuildTaskHandle(
weakref.proxy(self), self.nc, root_url=self.root_url,
build_tasks_href=self.root.get_href_by_name("build_tasks")
)
self._mock_chroots = MockChrootHandle(
weakref.proxy(self), self.nc, root_url=self.root_url,
href=self.root.get_href_by_name(u"mock_chroots")
)
self._post_init_done = True
开发者ID:0-T-0,项目名称:copr,代码行数:33,代码来源:client.py
示例13: testIsSame
def testIsSame(self):
s1 = _Stub()
s2 = _Stub()
r1 = weakref.ref(s1)
r2 = weakref.ref(s2)
p1 = weakref.proxy(s1)
p2 = weakref.proxy(s2)
assert IsSame(s1, s1)
assert not IsSame(s1, s2)
assert IsSame(s1, r1)
assert IsSame(s1, p1)
assert not IsSame(s1, r2)
assert not IsSame(s1, p2)
assert IsSame(p2, r2)
assert IsSame(r1, p1)
assert not IsSame(r1, p2)
with pytest.raises(ReferenceError):
IsSame(p1, p2)
开发者ID:nicoddemus,项目名称:ben10,代码行数:25,代码来源:pytest_weak_ref.py
示例14: __init__
def __init__(self, handler):
self.handler = weakref.proxy(handler)
self.log = weakref.proxy(self.handler.log)
if tornado.options.options.executor_type == 'threaded':
self.executor = frontik.jobs.get_threadpool_executor()
elif tornado.options.options.executor_type == 'ioloop':
self.executor = frontik.jobs.IOLoopExecutor
else:
raise ValueError('Cannot initialize XslProducer with executor_type {0!r}'.format(
tornado.options.options.executor_type))
self.xml_cache = self.handler.ph_globals.xml.xml_cache
self.xsl_cache = self.handler.ph_globals.xml.xsl_cache
self.doc = frontik.doc.Doc(root_node=etree.Element('doc', frontik='true'))
self.transform = None
self.transform_filename = None
if not self.handler.config.apply_xsl:
self.log.debug('ignoring set_xsl() because config.apply_xsl=%s', self.handler.config.apply_xsl)
self.apply_xsl = False
elif frontik.util.get_cookie_or_url_param_value(self.handler, 'noxsl') is not None:
self.handler.require_debug_access()
self.log.debug('ignoring set_xsl() because noxsl parameter is set')
self.apply_xsl = False
else:
self.apply_xsl = True
开发者ID:danila-hh,项目名称:frontik,代码行数:28,代码来源:xsl_producer.py
示例15: solve
def solve(self):
dm = self.snes.getDM()
nlevel = len(self.ctx._problems)
dm.setAppCtx(weakref.proxy(self.ctx))
dm.setCreateMatrix(self.ctx.create_matrix)
# FIXME: Need to set this up on the subDMs
for i in range(nlevel - 1, 0, -1):
dm = dm.coarsen()
dm.setAppCtx(weakref.proxy(self.ctx))
for i in range(nlevel - 1):
dm.setCreateInterpolation(create_interpolation)
dm.setCreateInjection(create_injection)
dm.setCreateMatrix(self.ctx.create_matrix)
dm = dm.refine()
self.snes.setFromOptions()
for bc in self.problems[-1].bcs:
bc.apply(self.problems[-1].u)
with self.problems[-1].u.dat.vec as v:
self.snes.solve(None, v)
firedrake.solving_utils.check_snes_convergence(self.snes)
开发者ID:alsgregory,项目名称:firedrake,代码行数:26,代码来源:solver_hierarchy.py
示例16: __init__
def __init__(self, name=None, parent=None, clear_lookup=True,
project=None):
self._name = name
if name is None:
self._name = u"Default Segment Category"
self._id = self.nextid
if clear_lookup:
self.id2obj.clear()
self.id2obj[self._id] = self
# weakref.proxy to this segment's parent segment.
# If segment is child of project node in gui tree, then parent
# should be None.
# Get using parent property.
self._parent = None
if parent:
if isinstance(parent, ProxyType):
self._parent = parent
else:
self._parent = proxy(parent)
# List of 0 - N child (sub) segments associated with this segment.
# If segment has no children, then _childsegments should be [].
# Get childsegments property.
self._childsegments = []
self._childsegment_ids = []
# If a segment is locked, it can not be deleted or modified.
self._locked = False
if project:
if isinstance(project, ProxyType):
PenDataSegmentCategory._project = project
else:
PenDataSegmentCategory._project = proxy(project)
开发者ID:Mark-Torrance,项目名称:OpenHandWrite,代码行数:34,代码来源:segment.py
示例17: __init__
def __init__(self, manager, module, message):
self.manager = weakref.proxy(manager)
self.module = None
if module is not None:
self.module = weakref.proxy(module)
self.kmail = message
self._info = message.toPyKol()
开发者ID:ijzer,项目名称:cwbot-ndy,代码行数:7,代码来源:kmailContainer.py
示例18: __init__
def __init__(self, plugins):
super(MigrationPlugin, self).__init__()
self.__bwProto = weakref.proxy(plugins[PROTO_TYPE.BW])
self.__bw2Proto = weakref.proxy(plugins[PROTO_TYPE.BW_CHAT2])
self.__xmppProto = weakref.proxy(plugins[PROTO_TYPE.XMPP])
self.__contacts = None
return
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:7,代码来源:__init__.py
示例19: test_proxy_reuse
def test_proxy_reuse(self):
o = C()
proxy1 = weakref.proxy(o)
ref = weakref.ref(o)
proxy2 = weakref.proxy(o)
self.assert_(proxy1 is proxy2,
"proxy object w/out callback should have been re-used")
开发者ID:alkorzt,项目名称:pypy,代码行数:7,代码来源:test_weakref.py
示例20: __init__
def __init__(self, registry, parent, command, target=None, is_background=False):
super(ShBaseThread, self).__init__(group=None,
target=target,
name='_shthread',
args=(),
kwargs=None)
# Registry management
self.registry = weakref.proxy(registry)
self.job_id = None # to be set by the registry
registry.add_worker(self)
# The command that the thread runs
if command.__class__.__name__ == 'ShIO':
self.command = ''.join(command._buffer)[::-1].strip()
else:
self.command = command
self.parent = weakref.proxy(parent)
# Set up the state based on parent's state
self.state = ShState.new_from_parent(parent.state)
self.killed = False
self.child_thread = None
self.set_background(is_background)
开发者ID:DocVaughan,项目名称:Pythonista,代码行数:27,代码来源:shthreads.py
注:本文中的weakref.proxy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论