Norman Fung <norman.lm.f...@gmail.com> added the comment:
Thanks Andrew for heads up. *1. My laptop (Windows 10) *with no changes runs happily with no error from here. python 3.8.5 asyncio 3.4.3 2. *My Windows VM (AWS EC2)* is where the whole mess is happening. I *upgraded *from Python 3.8.5 to 3.9.7. Asynio stayed 3.4.3, no change. I manually overwrite C:\ProgramData\Anaconda3\Lib\asyncio\task.py with what's here https://github.com/python/cpython/pull/31441/files (Only https://github.com/asvetlov/cpython/blob/150ef068c77abc6a5e7ba97397ac65113dba355a/Lib/asyncio/tasks.py ) Before I made this change, the error was: File "src\xxx\xxx.py", line 37, in _invoke_runners one_loop.run_until_complete(runner.xxx(xxx, xxx)) File "C:\ProgramData\Anaconda3\lib\site-packages\nest_asyncio.py", line 90, in run_until_complete self._run_once() File "C:\ProgramData\Anaconda3\lib\site-packages\nest_asyncio.py", line 127, in _run_once handle._run() File "C:\ProgramData\Anaconda3\lib\site-packages\nest_asyncio.py", line 196, in run ctx.run(self._callback, *self._args) File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 356, in _set_state _copy_future_state(other, future) File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 335, in _copy_future_state dest.set_result(result) File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 237, in set_result self.__schedule_callbacks() File "C:\ProgramData\Anaconda3\lib\asyncio\futures.py", line 149, in __schedule_callbacks self._loop.call_soon(callback, self, context=ctx) Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\nest_asyncio.py", line 196, in run ctx.run(self._callback, *self._args) File "C:\ProgramData\Anaconda3\lib\asyncio\tasks.py", line 762, in _done_callback if outer.done(): NameError: free variable 'outer' referenced before assignment in enclosing scope After I upgraded python to 3.9.7 and overwrite task.py, a different error (but also in asyncio stack): 2022-02-26 06:48:27,047 casin0: @slack algo_order.id: 13 #8 Algo tick level error casin0 uat <class 'RuntimeError'> Non-thread-safe operation invoked on an event loop other than the current one Traceback (most recent call last): File "C:\dev\xxx.py", line 547, in xxx await asyncio.sleep(algo.param.interval_ms / 1000) File "C:\ProgramData\Anaconda3\lib\asyncio\tasks.py", line 651, in sleep h = loop.call_later(delay, File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 714, in call_later timer = self.call_at(self.time() + delay, callback, *args, File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 727, in call_at self._check_thread() File "C:\ProgramData\Anaconda3\lib\asyncio\base_events.py", line 785, in _check_thread raise RuntimeError( RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one On Sat, Feb 26, 2022 at 2:36 PM Andrew Svetlov <rep...@bugs.python.org> wrote: > > Andrew Svetlov <andrew.svet...@gmail.com> added the comment: > > Also, fix is 1 week old. There are no python releases with the fix > included yet. > > On Sat, Feb 26, 2022, 06:58 Norman Fung <rep...@bugs.python.org> wrote: > > > > > Norman Fung <norman.lm.f...@gmail.com> added the comment: > > > > Thanks Jelle, let me try upgrade first. > > > > Norman > > > > On Sat, Feb 26, 2022 at 9:27 AM Jelle Zijlstra <rep...@bugs.python.org> > > wrote: > > > > > > > > Jelle Zijlstra <jelle.zijls...@gmail.com> added the comment: > > > > > > 3.8 is only receiving security fixes now. Please upgrade. If you cannot > > > upgrade, I suggest manually applying the patch from > > > https://github.com/python/cpython/pull/31441/files to your > installation > > > of Python. > > > > > > ---------- > > > nosy: +Jelle Zijlstra > > > resolution: -> out of date > > > stage: -> resolved > > > status: open -> closed > > > > > > _______________________________________ > > > Python tracker <rep...@bugs.python.org> > > > <https://bugs.python.org/issue46859> > > > _______________________________________ > > > > > > > ---------- > > > > _______________________________________ > > Python tracker <rep...@bugs.python.org> > > <https://bugs.python.org/issue46859> > > _______________________________________ > > > > ---------- > > _______________________________________ > Python tracker <rep...@bugs.python.org> > <https://bugs.python.org/issue46859> > _______________________________________ > ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46859> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com