python-trio / python-trio/trio
Support Pythonista (iOS python environment)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.3k
- Forks
- 431
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 6
Description
@mikaelho reports in https://github.com/python-trio/trio/issues/673#issuecomment-424958895 that on Pythonista, signal.getsignal(signal.SIGINT) has been hacked somehow to return None. But trio._util.is_main_thread assumes that the return value from getsignal is a valid input to signal; specifically it does:
signal.signal(signal.SIGINT, signal.getsignal(signal.SIGINT))
But when getsignal returns None, this doesn't work, so is_main_thread crashes, and this makes trio unusable in Pythonista.
I'm not really sure how Pythonista works or what the right thing to do here is... in regular Python, getsignal cannot return None, so I guess we can detect when we're on Pythonista, but then what? Does iOS even have signals? Does Pythonista have any way to do control-C?
A simple hack would be to add a check for getsignal returning None, and if it does then return False from is_main_thread – this would effectively disable signal handling on Pythonista, which seems like plausibly the right thing to do?
We might need to rewrite is_main_thread entirely anyway, to fix #673.
@mikaelho While we're at it, what does this return on Pythonista?
signal.signal(signal.SIGINT, signal.SIG_DFL)
?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at trio._util.is_main_thread and reproduce Pythonista's signal.getsignal(signal.SIGINT) behavior, comparing it with the regular-Python assumption described here and the related #673 discussion. Determine whether signal.signal(signal.SIGINT, signal.SIG_DFL) works there and define support as avoiding the crash without breaking main-thread or signal behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100