Package proton :: Module _selectable
[frames] | no frames]

Source Code for Module proton._selectable

 1  # 
 2  # Licensed to the Apache Software Foundation (ASF) under one 
 3  # or more contributor license agreements.  See the NOTICE file 
 4  # distributed with this work for additional information 
 5  # regarding copyright ownership.  The ASF licenses this file 
 6  # to you under the Apache License, Version 2.0 (the 
 7  # "License"); you may not use this file except in compliance 
 8  # with the License.  You may obtain a copy of the License at 
 9  # 
10  #   http://www.apache.org/licenses/LICENSE-2.0 
11  # 
12  # Unless required by applicable law or agreed to in writing, 
13  # software distributed under the License is distributed on an 
14  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
15  # KIND, either express or implied.  See the License for the 
16  # specific language governing permissions and limitations 
17  # under the License. 
18  # 
19   
20  from __future__ import absolute_import 
21   
22   
23  from ._events import Event 
24 25 -class Selectable(object):
26
27 - def __init__(self, delegate, reactor):
28 self._delegate = delegate 29 self.reading = False 30 self.writing = False 31 self._deadline = 0 32 self._terminal = False 33 self._terminated = False 34 self._collector = None 35 self._reactor = reactor
36
37 - def release(self):
38 if self._delegate: 39 self._delegate.close()
40
41 - def __getattr__(self, name):
42 if self._delegate: 43 return getattr(self._delegate, name) 44 else: 45 return None
46
47 - def _get_deadline(self):
48 tstamp = self._deadline 49 if tstamp: 50 return tstamp 51 else: 52 return None
53
54 - def _set_deadline(self, deadline):
55 if not deadline: 56 self._deadline = 0 57 else: 58 self._deadline = deadline
59 60 deadline = property(_get_deadline, _set_deadline) 61
62 - def collect(self, collector):
63 self._collector = collector
64
65 - def push_event(self, context, type):
66 if self._collector: 67 self._collector.put(context, type)
68
69 - def update(self):
70 if not self._terminated: 71 if self._terminal: 72 self._terminated = True 73 self.push_event(self, Event.SELECTABLE_FINAL) 74 else: 75 self.push_event(self, Event.SELECTABLE_UPDATED)
76
77 - def readable(self):
79
80 - def writable(self):
82
83 - def expired(self):
85 86 @property
87 - def is_terminal(self):
88 return self._terminal
89
90 - def terminate(self):
91 self._terminal = True
92