Opened 13 years ago

Closed 12 years ago

#1739 defect closed duplicate (duplicate)

(patch) Removing system event triggers while firing does the wrong thing.

Reported by: antony Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: therve Branch:


If a function registered to run "before" a system event tries to remove itself from the system events (this may sound silly, I admit, but it's convenient if the same function is used to stop an operation whether because the reactor is stopping or because a user asked for it), a different, possibly unexecuted trigger is removed.

This happens because when iterating over the triggers, the reactor base's removeSystemEventTrigger executes the triggers while iterating over them. This is resolved by iterating over a copy.

Attachments (2) (374 bytes) - added by antony 13 years ago.
patch for twisted.internet.base (1.2 KB) - added by antony 13 years ago.
unit test

Download all attachments as: .zip

Change History (7)

Changed 13 years ago by antony

Attachment: added

patch for twisted.internet.base

Changed 13 years ago by antony

Attachment: added

unit test

comment:1 Changed 13 years ago by Jean-Paul Calderone

Iterating over a copy probably isn't the best solution here. Instead, the entire event system needs to be made re-entrant safe, particularly with respect to Deferreds. There are a lot of problems like the specific one described in this ticket.

comment:2 Changed 13 years ago by antony

Okay. I decided to implement a different solution to my specific problem to avoid relying on the re-entrancy of twisted system events. You can still use my test though.

comment:3 Changed 12 years ago by therve

Cc: therve added

See #2509. It should have been closed as duplicate of this one, but the branch was already there.

comment:4 Changed 12 years ago by Glyph

Resolution: duplicate
Status: newclosed

Given that the other one has superseded this, I'm going to close this one as a duplicate.

comment:5 Changed 8 years ago by <automation>

Owner: itamarst deleted
Note: See TracTickets for help on using tickets.