I was playing with BocPy and got some weird behaviour when using wait(stats=True) in the root of the __main__ module. Calling wait(stats=True) works just fine, but storing the result in a global variable stats = wait(stats=True) causes an exception AttributeError: 'NoneType' object has no attribute 'join'
Here is a the small example
from bocpy import Cown, when, wait
c = Cown([1, 2, 3])
def main():
@when(c)
def x(c):
print(f"1: {hex(id(c.value))}: {c.value}")
if __name__ == "__main__":
main()
wait(stats=True) # Is fine
if __name__ == "__main__":
main()
stats = wait(stats=True) # Runtime Error
For me, this results in the following exception:
Traceback (most recent call last):
File "<workspace>/bocpy/pyrona.py", line 11, in <module>
main()
~~~~^^
File "<workspace>/bocpy/pyrona.py", line 6, in main
@when(c)
~~~~^^^
File "<workspace>/bocpy/src/bocpy/behaviors.py", line 1990, in when_factory
start(module=get_caller_module())
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<workspace>/bocpy/src/bocpy/behaviors.py", line 1960, in start
BEHAVIORS.start(module)
~~~~~~~~~~~~~~~^^^^^^^^
File "<workspace>/bocpy/src/bocpy/behaviors.py", line 1034, in start
exec(
~~~~^
compile(export.code, main_export_file, "exec"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
main_export.__dict__,
^^^^^^^^^^^^^^^^^^^^^
)
^
File "<bocpy:main:__main__>", line 9, in <module>
stats = wait(stats=True)
File "<workspace>/bocpy/src/bocpy/behaviors.py", line 2134, in wait
BEHAVIORS.stop(_remaining())
~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "<workspace>/bocpy/src/bocpy/behaviors.py", line 1390, in stop
self.noticeboard.join(_remaining())
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'join'
This can be fixed by moving the wait into the main() function, but it's still a bit weird.
I was playing with BocPy and got some weird behaviour when using
wait(stats=True)in the root of the__main__module. Callingwait(stats=True)works just fine, but storing the result in a global variablestats = wait(stats=True)causes an exceptionAttributeError: 'NoneType' object has no attribute 'join'Here is a the small example
For me, this results in the following exception:
This can be fixed by moving the
waitinto themain()function, but it's still a bit weird.