forked from M-Labs/artiq
Improve Python 3.7 compatibility.
async is now a full (non-contextual) keyword. There are two more instances: - artiq/frontend/artiq_client.py - artiq/devices/thorlabs_tcube/driver.py It is not immediately clear how to fix those, so they are left for later work.
This commit is contained in:
parent
cd725a8352
commit
49682d0159
|
@ -1019,7 +1019,7 @@ class Stitcher:
|
||||||
|
|
||||||
function_type = types.TRPC(ret_type,
|
function_type = types.TRPC(ret_type,
|
||||||
service=self.embedding_map.store_object(host_function),
|
service=self.embedding_map.store_object(host_function),
|
||||||
async=is_async)
|
is_async=is_async)
|
||||||
self.functions[function] = function_type
|
self.functions[function] = function_type
|
||||||
return function_type
|
return function_type
|
||||||
|
|
||||||
|
|
|
@ -1342,7 +1342,7 @@ class LLVMIRGenerator:
|
||||||
llargptr = self.llbuilder.gep(llargs, [ll.Constant(lli32, index)])
|
llargptr = self.llbuilder.gep(llargs, [ll.Constant(lli32, index)])
|
||||||
self.llbuilder.store(llargslot, llargptr)
|
self.llbuilder.store(llargslot, llargptr)
|
||||||
|
|
||||||
if fun_type.async:
|
if fun_type.is_async:
|
||||||
self.llbuilder.call(self.llbuiltin("rpc_send_async"),
|
self.llbuilder.call(self.llbuiltin("rpc_send_async"),
|
||||||
[llservice, lltagptr, llargs])
|
[llservice, lltagptr, llargs])
|
||||||
else:
|
else:
|
||||||
|
@ -1352,7 +1352,7 @@ class LLVMIRGenerator:
|
||||||
# Don't waste stack space on saved arguments.
|
# Don't waste stack space on saved arguments.
|
||||||
self.llbuilder.call(self.llbuiltin("llvm.stackrestore"), [llstackptr])
|
self.llbuilder.call(self.llbuiltin("llvm.stackrestore"), [llstackptr])
|
||||||
|
|
||||||
if fun_type.async:
|
if fun_type.is_async:
|
||||||
# If this RPC is called using an `invoke` ARTIQ IR instruction, there will be
|
# If this RPC is called using an `invoke` ARTIQ IR instruction, there will be
|
||||||
# no other instructions in this basic block. Since this RPC is async, it cannot
|
# no other instructions in this basic block. Since this RPC is async, it cannot
|
||||||
# possibly raise an exception, so add an explicit jump to the normal successor.
|
# possibly raise an exception, so add an explicit jump to the normal successor.
|
||||||
|
|
|
@ -311,14 +311,14 @@ class TRPC(Type):
|
||||||
:ivar ret: (:class:`Type`)
|
:ivar ret: (:class:`Type`)
|
||||||
return type
|
return type
|
||||||
:ivar service: (int) RPC service number
|
:ivar service: (int) RPC service number
|
||||||
:ivar async: (bool) whether the RPC blocks until return
|
:ivar is_async: (bool) whether the RPC blocks until return
|
||||||
"""
|
"""
|
||||||
|
|
||||||
attributes = OrderedDict()
|
attributes = OrderedDict()
|
||||||
|
|
||||||
def __init__(self, ret, service, async=False):
|
def __init__(self, ret, service, is_async=False):
|
||||||
assert isinstance(ret, Type)
|
assert isinstance(ret, Type)
|
||||||
self.ret, self.service, self.async = ret, service, async
|
self.ret, self.service, self.is_async = ret, service, is_async
|
||||||
|
|
||||||
def find(self):
|
def find(self):
|
||||||
return self
|
return self
|
||||||
|
@ -326,7 +326,7 @@ class TRPC(Type):
|
||||||
def unify(self, other):
|
def unify(self, other):
|
||||||
if isinstance(other, TRPC) and \
|
if isinstance(other, TRPC) and \
|
||||||
self.service == other.service and \
|
self.service == other.service and \
|
||||||
self.async == other.async:
|
self.is_async == other.is_async:
|
||||||
self.ret.unify(other.ret)
|
self.ret.unify(other.ret)
|
||||||
elif isinstance(other, TVar):
|
elif isinstance(other, TVar):
|
||||||
other.unify(self)
|
other.unify(self)
|
||||||
|
@ -343,7 +343,7 @@ class TRPC(Type):
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return isinstance(other, TRPC) and \
|
return isinstance(other, TRPC) and \
|
||||||
self.service == other.service and \
|
self.service == other.service and \
|
||||||
self.async == other.async
|
self.is_async == other.is_async
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return not (self == other)
|
return not (self == other)
|
||||||
|
@ -742,7 +742,7 @@ class TypePrinter(object):
|
||||||
return signature
|
return signature
|
||||||
elif isinstance(typ, TRPC):
|
elif isinstance(typ, TRPC):
|
||||||
return "[rpc{} #{}](...)->{}".format(typ.service,
|
return "[rpc{} #{}](...)->{}".format(typ.service,
|
||||||
" async" if typ.async else "",
|
" async" if typ.is_async else "",
|
||||||
self.name(typ.ret, depth + 1))
|
self.name(typ.ret, depth + 1))
|
||||||
elif isinstance(typ, TBuiltinFunction):
|
elif isinstance(typ, TBuiltinFunction):
|
||||||
return "<function {}>".format(typ.name)
|
return "<function {}>".format(typ.name)
|
||||||
|
|
|
@ -403,7 +403,7 @@ class CommKernel:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def _serve_rpc(self, embedding_map):
|
def _serve_rpc(self, embedding_map):
|
||||||
async = self._read_bool()
|
is_async = self._read_bool()
|
||||||
service_id = self._read_int32()
|
service_id = self._read_int32()
|
||||||
args, kwargs = self._receive_rpc_args(embedding_map)
|
args, kwargs = self._receive_rpc_args(embedding_map)
|
||||||
return_tags = self._read_bytes()
|
return_tags = self._read_bytes()
|
||||||
|
@ -413,9 +413,9 @@ class CommKernel:
|
||||||
else:
|
else:
|
||||||
service = embedding_map.retrieve_object(service_id)
|
service = embedding_map.retrieve_object(service_id)
|
||||||
logger.debug("rpc service: [%d]%r%s %r %r -> %s", service_id, service,
|
logger.debug("rpc service: [%d]%r%s %r %r -> %s", service_id, service,
|
||||||
(" (async)" if async else ""), args, kwargs, return_tags)
|
(" (async)" if is_async else ""), args, kwargs, return_tags)
|
||||||
|
|
||||||
if async:
|
if is_async:
|
||||||
service(*args, **kwargs)
|
service(*args, **kwargs)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue