~ubuntu-branches/ubuntu/trusty/twisted/trusty-proposed

« back to all changes in this revision

Viewing changes to twisted/internet/kqreactor.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-01-08 00:19:41 UTC
  • mfrom: (1.3.1) (44.2.2 sid)
  • Revision ID: package-import@ubuntu.com-20140108001941-kxhzbyi4a40sc08r
Tags: 13.2.0-1ubuntu1
* Merge with Debian; remaining changes:
  - Keep the preliminary python3 support, but don't enable it.
  - Try to use plain pygtkcompat and fall back to gi.pygtkcompat, to
    avoid a DeprecationWarning, and a crash.
  - Use new io_add_watch api on new versions of pygobject.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        write readiness notifications will be present as values in this
49
49
        dictionary.
50
50
 
51
 
    @ivar _reads: A dictionary mapping integer file descriptors to arbitrary
52
 
        values (this is essentially a set).  Keys in this dictionary will be
53
 
        registered with C{_kq} for read readiness notifications which will be
54
 
        dispatched to the corresponding L{FileDescriptor} instances in
55
 
        C{_selectables}.
 
51
    @ivar _reads: A set containing integer file descriptors.  Values in this
 
52
        set will be registered with C{_kq} for read readiness notifications
 
53
        which will be dispatched to the corresponding L{FileDescriptor}
 
54
        instances in C{_selectables}.
56
55
 
57
 
    @ivar _writes: A dictionary mapping integer file descriptors to arbitrary
58
 
        values (this is essentially a set).  Keys in this dictionary will be
59
 
        registered with C{_kq} for write readiness notifications which will be
60
 
        dispatched to the corresponding L{FileDescriptor} instances in
61
 
        C{_selectables}.
 
56
    @ivar _writes: A set containing integer file descriptors.  Values in this
 
57
        set will be registered with C{_kq} for write readiness notifications
 
58
        which will be dispatched to the corresponding L{FileDescriptor}
 
59
        instances in C{_selectables}.
62
60
    """
63
61
    implements(IReactorFDSet, IReactorDaemonize)
64
62
 
74
72
            - people.freebsd.org/~jlemon/papers/kqueue.pdf
75
73
        """
76
74
        self._kq = kqueue()
77
 
        self._reads = {}
78
 
        self._writes = {}
 
75
        self._reads = set()
 
76
        self._writes = set()
79
77
        self._selectables = {}
80
78
        posixbase.PosixReactorBase.__init__(self)
81
79
 
133
131
                pass
134
132
            finally:
135
133
                self._selectables[fd] = reader
136
 
                self._reads[fd] = 1
 
134
                self._reads.add(fd)
137
135
 
138
136
 
139
137
    def addWriter(self, writer):
148
146
                pass
149
147
            finally:
150
148
                self._selectables[fd] = writer
151
 
                self._writes[fd] = 1
 
149
                self._writes.add(fd)
152
150
 
153
151
 
154
152
    def removeReader(self, reader):
168
166
            else:
169
167
                return
170
168
        if fd in self._reads:
171
 
            del self._reads[fd]
 
169
            self._reads.remove(fd)
172
170
            if fd not in self._writes:
173
171
                del self._selectables[fd]
174
172
            if not wasLost:
195
193
            else:
196
194
                return
197
195
        if fd in self._writes:
198
 
            del self._writes[fd]
 
196
            self._writes.remove(fd)
199
197
            if fd not in self._reads:
200
198
                del self._selectables[fd]
201
199
            if not wasLost: