forked from M-Labs/artiq
1
0
Fork 0

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:
whitequark 2019-01-12 13:17:59 +00:00
parent cd725a8352
commit 49682d0159
4 changed files with 12 additions and 12 deletions

View File

@ -1019,7 +1019,7 @@ class Stitcher:
function_type = types.TRPC(ret_type,
service=self.embedding_map.store_object(host_function),
async=is_async)
is_async=is_async)
self.functions[function] = function_type
return function_type

View File

@ -1342,7 +1342,7 @@ class LLVMIRGenerator:
llargptr = self.llbuilder.gep(llargs, [ll.Constant(lli32, index)])
self.llbuilder.store(llargslot, llargptr)
if fun_type.async:
if fun_type.is_async:
self.llbuilder.call(self.llbuiltin("rpc_send_async"),
[llservice, lltagptr, llargs])
else:
@ -1352,7 +1352,7 @@ class LLVMIRGenerator:
# Don't waste stack space on saved arguments.
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
# 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.

View File

@ -311,14 +311,14 @@ class TRPC(Type):
:ivar ret: (:class:`Type`)
return type
: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()
def __init__(self, ret, service, async=False):
def __init__(self, ret, service, is_async=False):
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):
return self
@ -326,7 +326,7 @@ class TRPC(Type):
def unify(self, other):
if isinstance(other, TRPC) and \
self.service == other.service and \
self.async == other.async:
self.is_async == other.is_async:
self.ret.unify(other.ret)
elif isinstance(other, TVar):
other.unify(self)
@ -343,7 +343,7 @@ class TRPC(Type):
def __eq__(self, other):
return isinstance(other, TRPC) and \
self.service == other.service and \
self.async == other.async
self.is_async == other.is_async
def __ne__(self, other):
return not (self == other)
@ -742,7 +742,7 @@ class TypePrinter(object):
return signature
elif isinstance(typ, TRPC):
return "[rpc{} #{}](...)->{}".format(typ.service,
" async" if typ.async else "",
" async" if typ.is_async else "",
self.name(typ.ret, depth + 1))
elif isinstance(typ, TBuiltinFunction):
return "<function {}>".format(typ.name)

View File

@ -403,7 +403,7 @@ class CommKernel:
return msg
def _serve_rpc(self, embedding_map):
async = self._read_bool()
is_async = self._read_bool()
service_id = self._read_int32()
args, kwargs = self._receive_rpc_args(embedding_map)
return_tags = self._read_bytes()
@ -413,9 +413,9 @@ class CommKernel:
else:
service = embedding_map.retrieve_object(service_id)
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)
return