leezu commented on a change in pull request #17749: Fix races in block scope
and deferred_init
URL: https://github.com/apache/incubator-mxnet/pull/17749#discussion_r387206282
##########
File path: python/mxnet/gluon/block.py
##########
@@ -48,8 +48,9 @@ class _BlockScope(object):
def __init__(self, block):
self._block = block
self._counter = {}
- self._old_scope = None
- self._name_scope = None
+ self._local = threading.local()
Review comment:
How about using contextvars here? This will ensure the code is compatible
with python coroutines.
https://docs.python.org/3/library/contextvars.html
You need to include https://pypi.org/project/contextvars/ as dependency on
Python 3.5, 3.6
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services