Ticket #3063 enhancement new

Opened 5 years ago

Last modified 14 months ago

instantiating a reactor leaks file descriptors/handles by way of the wakers

Reported by: radix Owned by: itamar
Priority: high Milestone:
Component: core Keywords:
Cc: Branch: branches/cleanup-waker-3063-2
Author: itamarst, exarkun Launchpad Bug:

Description

On posix reactors, a waker is instantiated and file descriptors are set up when the reactor is instantiated. In order to make reactors usable in an isolated way reasonably, these file descriptors must be cleaned up. By default, most file descriptors are cleaned up when the reactor is stopped, but the waker is explicitly left out for probably rather stupid reasons (so the reactor can be restarted; but this can be facilitated in a better way). Here's the proposed changes:

  • Waker should be installed when run() is called (or perhaps specifically startRunning), instead of when the reactor is instantiated.
  • Waker should be removed when reactor is stopped (probably "after", "shutdown"). There are some trivially tricky issues involved with this; the trigger for removing the waker MUST be added before we fire the "run" event, to deal with cases where reactor.callWhenRunning(reactor.stop) are used.
  • If we move waker installation to startRunning instead of instantiation, that means threads cannot be initialized properly until startRunning, either. When threads are initialized, the threaded resolver is installed. That means if we make this change, the behavior of reactor.resolve before reactor.run is called will change so it blocks. I can't currently think of a reason that this would be bad, but it might be.
  • There may be other similar issues to the resolve() issue.

Change History

1

Changed 4 years ago by glyph

  • owner changed from glyph to radix
  • priority changed from normal to high

2

Changed 3 years ago by exarkun

As of #733, there are multiple wakers on some reactors. We should be sure to clean them all up when we fix this.

3

Changed 3 years ago by exarkun

  • branch set to branches/cleanup-waker-3063
  • branch_author set to exarkun

(In [28513]) Branching to 'cleanup-waker-3063'

4

Changed 2 years ago by <automation>

  • owner radix deleted

5

Changed 14 months ago by itamar

  • owner set to itamar

6

Changed 14 months ago by itamarst

  • branch changed from branches/cleanup-waker-3063 to branches/cleanup-waker-3063-2
  • branch_author changed from exarkun to itamarst, exarkun

(In [33908]) Branching to 'cleanup-waker-3063-2'

Note: See TracTickets for help on using tickets.