[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-26 Thread STINNER Victor
STINNER Victor added the comment: Thanks for the review. I commited my change in Tulip, Python 3.4 & 3.5. -- resolution: -> fixed status: open -> closed ___ Python tracker ___ _

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-26 Thread Roundup Robot
Roundup Robot added the comment: New changeset 4e8ac4173b3c by Victor Stinner in branch '3.4': Issue #22926: In debug mode, call_soon(), call_at() and call_later() methods of https://hg.python.org/cpython/rev/4e8ac4173b3c -- nosy: +python-dev ___ Pyth

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-25 Thread Guido van Rossum
Guido van Rossum added the comment: SGTM. Merry Xmas! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-25 Thread STINNER Victor
STINNER Victor added the comment: I'm going to commit check_thread-3.patch if nobody complains: in debug mode, call_soon(), call_at() and call_later() now check threading.get_ident() to ensure that they are called from the thread running the event loop. -- Added file: http://bugs.pytho

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-20 Thread STINNER Victor
Changes by STINNER Victor : Added file: http://bugs.python.org/file37519/bench_call_soon.py ___ Python tracker ___ ___ Python-bugs-list mailin

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-20 Thread STINNER Victor
STINNER Victor added the comment: Rebased patch which now always check the thread, even in release mode. Summary of the current version of the patch (check_thread-2.patch): - call_soon/call_at now checks if they are called from the thread running the event loop - the check is only done when th

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-17 Thread STINNER Victor
STINNER Victor added the comment: Guido> So in order to do correct diagnostics here we would have to add an "owning thread" pointer to every event loop; I didn't understand why this approach was not taken when the check was introduced. I was surprised that get_event_loop() was used for the che

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-16 Thread Guido van Rossum
Guido van Rossum added the comment: Oh sorry. I'm in too much of a hurry. :-( The problem is that the thread may not have a loop, but the loop still has a tread. E.g. the tests intentionally call set_event_loop(None) to make sure that no code depends on the implict event loop. An app should be a

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-16 Thread STINNER Victor
STINNER Victor added the comment: 2014-12-17 0:53 GMT+01:00 Guido van Rossum : > Well, the PEP clearly states that get_event_loop() should never return None > and raise an exception if the context has no environment. (Where context ~~ > thread.) You don't reply to my question, or I misunderstood

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-16 Thread Guido van Rossum
Guido van Rossum added the comment: Well, the PEP clearly states that get_event_loop() should never return None and raise an exception if the context has no environment. (Where context ~~ thread.) On Tue, Dec 16, 2014 at 3:48 PM, STINNER Victor wrote: > > > STINNER Victor added the comment: > >

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-16 Thread STINNER Victor
STINNER Victor added the comment: Guido wrote: > I'm okay with this approach now. I'm not sure that I understood your opinion. Are you ok to raise an exception in debug mode if call_soon() is called from a thread which has no event loop attached? (Currently, an exception is already raised in

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-06 Thread Guido van Rossum
Guido van Rossum added the comment: I'm okay with this approach now. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-05 Thread Yury Selivanov
Yury Selivanov added the comment: Hi Victor, I left you some feedback in code review. I'm kind of leaning towards your proposal that we should force users to always use safe API. But I also understand Guido's point. -- ___ Python tracker

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-05 Thread STINNER Victor
STINNER Victor added the comment: Ok, here is an updated patch (version 2): - tests still ensure that the event loop is passed explicitly - call_soon() & cie now fail if the policy has no event loop set for the current thread (before it only failed if the event loop set in the policy was diffe

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-04 Thread Guido van Rossum
Guido van Rossum added the comment: On Thu, Dec 4, 2014 at 7:21 PM, Yury Selivanov wrote: > > 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 ide

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-04 Thread Yury Selivanov
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. > -

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-04 Thread Guido van Rossum
Guido van Rossum added the comment: Maybe only in debug mode? Getting thread ID or current thread may be expensive. Also it is conceivable that run... is called first from one thread and then from another. Maybe. On Dec 4, 2014 4:47 PM, "STINNER Victor" wrote: > > STINNER Victor added the comme

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-12-04 Thread STINNER Victor
STINNER Victor added the comment: Guido, Yury: What do you think? Does it sound reasonable to raise an exception if an event loop is used from the wrong thread? -- ___ Python tracker __

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-11-28 Thread STINNER Victor
STINNER Victor added the comment: Here is a patch without unit: - 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 - modify BaseEventLoop._assert_is_current_event_loop() to fail if the

[issue22926] asyncio: raise an exception when called from the wrong thread

2014-11-23 Thread STINNER Victor
Changes by STINNER Victor : -- title: asyncio: -> asyncio: raise an exception when called from the wrong thread ___ Python tracker ___ ___