Opened 13 years ago
Closed 10 years ago
#1246 defect closed fixed (fixed)
reactor.callWhenRunning is not in the Using Processes document
Reported by: | hagna | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | core | Keywords: | documentation |
Cc: | hagna, Thijs Triemstra | Branch: |
branches/callwhenrunning-doc-1246
branch-diff, diff-cov, branch-cov, buildbot |
Author: | thijs |
Description
Attachments (1)
Change History (17)
Changed 13 years ago by
Attachment: | example.py added |
---|
comment:2 Changed 12 years ago by
Cc: | hypatia removed |
---|---|
Component: | → core |
Owner: | changed from hypatia to edsuom |
comment:3 Changed 10 years ago by
Cc: | Thijs Triemstra added |
---|---|
Keywords: | review added |
Shall I create a patch that adds this to the core docs? Can anyone review this example?
comment:4 Changed 10 years ago by
Owner: | edsuom deleted |
---|---|
Priority: | high → normal |
comment:5 follow-up: 8 Changed 10 years ago by
Keywords: | review removed |
---|---|
Owner: | set to Thijs Triemstra |
This example is rather complex. A simpler example would be more like this (untested):
from twisted.internet.utils import getProcessOutput from twisted.internet import reactor d = getProcessOutput('/bin/echo', ['/bin/echo', 'foo']) def cbOutput(output): print output reactor.stop() d.addCallback(cbOutput) reactor.run()
This would better be written (for the time being) as
from twisted.internet.utils import getProcessOutput from twisted.internet import reactor def getOutput(): d = getProcessOutput('/bin/echo', ['/bin/echo', 'foo']) def cbOutput(output): print output reactor.stop() d.addCallback(cbOutput) reactor.callWhenRunning(getOutput) reactor.run()
comment:6 Changed 10 years ago by
Status: | new → assigned |
---|
comment:7 Changed 10 years ago by
author: | → thijs |
---|---|
Branch: | → branches/callwhenrunning-doc-1246 |
(In [24448]) Branching to 'callwhenrunning-doc-1246'
comment:8 Changed 10 years ago by
Keywords: | review added |
---|---|
Owner: | Thijs Triemstra deleted |
Status: | assigned → new |
Replying to exarkun:
This example is rather complex. A simpler example would be more like this (untested): ...
I added your example in a branch with the terse description hagna offered. Let me know how it looks and fits.
comment:9 follow-up: 11 Changed 10 years ago by
Keywords: | review removed |
---|---|
Owner: | set to Thijs Triemstra |
spawnprocess
in the prose should be capitalized properly and would probably benefit from being an API link. The reference to reactor.callWhenRunning
following it could be an API link too.
I'd suggest dropping the mention of a "signal handler" and just talk about how calling reactor.spawnProcess
before calling reactor.run
can lead to a race where process exit isn't noticed (and a warning emitted). Then it becomes more clear how using reactor.callWhenRunning
helps. This should also help make the statement "The way to get rid of a race condition..." more clear, because the actual race condition will have been defined in the document, which it currently isn't.
Also, my example contained a bug - getProcessOutput
does not take argv[0] as part of the argument list, but I included it because I always forget about that inconsistency.
Thanks!
comment:10 Changed 10 years ago by
Status: | new → assigned |
---|
comment:11 Changed 10 years ago by
Keywords: | review added |
---|---|
Owner: | changed from Thijs Triemstra to Jean-Paul Calderone |
Status: | assigned → new |
Replying to exarkun:
spawnprocess
in the prose should be capitalized properly and would probably benefit from being an API link. The reference toreactor.callWhenRunning
following it could be an API link too.I'd suggest dropping the mention of a "signal handler" and just talk about how calling
reactor.spawnProcess
before callingreactor.run
can lead to a race where process exit isn't noticed (and a warning emitted). Then it becomes more clear how usingreactor.callWhenRunning
helps. This should also help make the statement "The way to get rid of a race condition..." more clear, because the actual race condition will have been defined in the document, which it currently isn't.
Rewrote it in r24642, putting it up for review.
Also, my example contained a bug -
getProcessOutput
does not take argv[0] as part of the argument list, but I included it because I always forget about that inconsistency.
What does this mean, something like this?
- d = getProcessOutput('/bin/echo', ['/bin/echo', 'foo']) + d = getProcessOutput('/bin/echo')
comment:12 follow-up: 13 Changed 10 years ago by
It means d = getProcessOutput('/bin/echo', ['foo'])
comment:13 Changed 10 years ago by
comment:14 Changed 10 years ago by
Keywords: | review removed |
---|---|
Owner: | changed from Jean-Paul Calderone to Thijs Triemstra |
Looks good, please merge.
comment:15 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:16 Changed 7 years ago by
Owner: | Thijs Triemstra deleted |
---|