Message232173
> - 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. |
|
Date |
User |
Action |
Args |
2014-12-05 03:21:52 | yselivanov | set | recipients:
+ yselivanov, gvanrossum, vstinner |
2014-12-05 03:21:52 | yselivanov | set | messageid: <1417749712.43.0.707557293621.issue22926@psf.upfronthosting.co.za> |
2014-12-05 03:21:52 | yselivanov | link | issue22926 messages |
2014-12-05 03:21:51 | yselivanov | create | |
|