twisted / twisted/twisted

Add an equivalent to `isInIOThread` as a reactor method

Open
#5,153 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core enhancement new priority-low
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

exarkun's avatar @exarkun reported
Trac ID trac#5153
Type enhancement
Created 2011-06-13 21:46:24Z

twisted.python.threadable.isInIOThread is usable to determine if the code calling it is executing in the same thread as the reactor. This may be useful for making certain decisions (though Twisted doesn't currently use it anywhere outside of the test suite).

Notice the problem with that, however: the reactor. This API gets in the way of supporting multiple reactors, since its behavior no longer makes any sense once you have reactors running in more than one thread.

It could be replaced by a new reactor method which determines if the calling code is running in the same thread as the reactor the method is called on is running. This probably makes sense as a method on IReactorThreads, if we're allowed to add new methods to reactor interfaces (I forget if we are or not).

Once this is in place, we can deprecate twisted.python.threadable.isInIOThread and point at the reactor method to replace it.

Searchable metadata
trac-id__5153 5153
type__enhancement enhancement
reporter__exarkun exarkun
priority__low low
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__ 
time__1308001584000000 1308001584000000
changetime__1308001584000000 1308001584000000
version__None None
owner__ 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with twisted.python.threadable.isInIOThread and the IReactorThreads interface, then inspect the reactor implementations that would provide the reactor-specific behavior. Check the test suite for existing isInIOThread coverage. Done means a reactor method distinguishes its own thread, the legacy helper can be deprecated with a replacement reference, and the behavior is tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.