Mercurial > cosocket
comparison channels.py @ 59:b0f802c4fafc
Fixed what (I think) are channel memory management bugs.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 28 Apr 2009 22:07:52 -0700 |
parents | 425776983cf2 |
children | 43d37495e9d4 |
comparison
equal
deleted
inserted
replaced
58:7a2ecb3e800f | 59:b0f802c4fafc |
---|---|
24 if self.channel_name not in _channels: | 24 if self.channel_name not in _channels: |
25 _channels[self.channel_name] = {} | 25 _channels[self.channel_name] = {} |
26 self._fd = dispatcher.socket.fileno() | 26 self._fd = dispatcher.socket.fileno() |
27 _channels[self.channel_name][self._fd] = dispatcher | 27 _channels[self.channel_name][self._fd] = dispatcher |
28 | 28 |
29 def abort(self): | 29 def finalize(self): |
30 if (self.channel_name in _channels and | 30 if (self.channel_name in _channels and |
31 self._fd in _channels[self.channel_name]): | 31 self._fd in _channels[self.channel_name]): |
32 del _channels[self.channel_name][self._fd] | 32 del _channels[self.channel_name][self._fd] |
33 if not _channels[self.channel_name]: | |
34 del _channels[self.channel_name] | |
33 | 35 |
34 def until_message_received(channel_name): | 36 def until_message_received(channel_name): |
35 instruction = _until_message_received(channel_name) | 37 instruction = _until_message_received(channel_name) |
36 try: | 38 try: |
37 message = yield instruction | 39 message = yield instruction |
38 yield cosocket.return_value(message) | 40 yield cosocket.return_value(message) |
39 except GeneratorExit: | 41 finally: |
40 instruction.abort() | 42 instruction.finalize() |
41 raise |