Yury Selivanov added the comment:

> - modify tests to set the event loop to the newly created event loop, instead 
> of setting it to None

I'm not sure that this particular change is a great idea. I kind of liked that 
unittests ensure that loop is passed everywhere explicitly in asyncio.


> - modify get_event_loop() to always raise a RuntimeError if the thread has no 
> event loop. Before an AssertionError was not raised if python runs with -O 
> option

+1.


> - modify BaseEventLoop._assert_is_current_event_loop() to fail if the thread 
> has an event loop

Hm, I think I don't understand why this function doesn't to anything when there 
is no loop in the thread... Let's fix it. In your patch, you should also 
replace 'except AsserionError' with 'except RuntimeError'.


> Does it sound reasonable to raise an exception if an event loop is used from 
> the wrong thread?

I think we should in debug mode at least.


> Getting thread ID or current thread may be expensive.

Victor, can you benchmark this?  I'm pretty sure that Guido is right about 
this, but sometimes syscalls are pretty fast.  I doubt that a lot of people 
know about debug mode, so if it has a negligible cost I'd do the check every 
time.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22926>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to