def __init__ (self, auth, host, port=5672, virtual_host='/', heartbeat=0, consumer_cancel_notify=None, frame_max=0): self.port = port self.host = host self.auth = auth self.virtual_host = virtual_host self.heartbeat = heartbeat self.frame_state = 0 self.frames = coro.fifo() # collect body parts here. heh. self.body = [] self.next_content_consumer = None self.next_properties = None self.consumers = {} self.last_sent_before = coro.tsc_time.now_raw_posix_fsec() self.last_sent_after = coro.tsc_time.now_raw_posix_fsec() self.channels = {} self._exception_handler = None self._send_completion_handler = None self._recv_completion_handler = None self.consumer_cancel_notify = consumer_cancel_notify self.frame_max = frame_max # XXX implement read/write "channels" (coro). self._recv_loop_thread = None self._s_recv_sema = coro.semaphore(1) self._s_send_sema = coro.semaphore(1)
def __init__ (self, in_flight=20): self.queue = coro.fifo() self.qset = set() self.requested = set() self.ready = {} self.target = G.block_db.last_block self.running = False self.live_cv = coro.condition_variable() self.in_flight_sem = coro.semaphore (in_flight)
def __init__(self, in_flight=20): self.queue = coro.fifo() self.qset = set() self.requested = set() self.ready = {} self.target = G.block_db.last_block self.running = False self.live_cv = coro.condition_variable() self.in_flight_sem = coro.semaphore(in_flight)
def run(self): self.streams = {} self.deflate = deflator() self.inflate = inflator() self.ofifo = coro.fifo() self.obuf = coro.semaphore(self.output_buffer_size) coro.spawn(self.send_thread) try: self.read_frames() finally: self.ofifo.push(None)
def __init__ (self, host, port=80, conn=None, inflight=100): self.host = host self.inflight = coro.semaphore (inflight) if conn is None: self.conn = coro.tcp_sock() self.conn.connect ((host, port)) else: self.conn = conn self.stream = coro.read_stream.sock_stream (self.conn) self.pending = coro.fifo() coro.spawn (self.read_thread)
def handle_request (self, request): sid, fifo = self.find_session (request) if fifo is None: # login fifo = coro.fifo() fifo.push (request) sid = self.gen_session_id() request['set-cookie'] = 'session=%s' % (sid,) self.sessions[sid] = fifo coro.spawn (self.wrap, sid, fifo) else: fifo.push (request)
def __init__ (self, conn): self.conn = conn self.conn.send ( '\xff\xfc\x01' # IAC WONT ECHO '\xff\xfb\x03' # IAC WILL SUPPRESS_GO_AHEAD '\xff\xfc"' # IAC WONT LINEMODE ) # turn off the cursor self.conn.send (CSI + '?25l') self.fifo = coro.fifo() self.redraw() self.t0 = coro.spawn (self.listen) self.t1 = coro.spawn (self.writer) self.exit = False
def __init__ (self, auth, host, port=5672, virtual_host='/', heartbeat=0): self.port = port self.host = host self.auth = auth self.virtual_host = virtual_host self.heartbeat = heartbeat self.frame_state = 0 self.frames = coro.fifo() # collect body parts here. heh. self.body = [] self.next_content_consumer = None self.next_properties = None self.consumers = {} self.closed_cv = coro.condition_variable() self.last_send = coro.now self.channels = {}
def __init__(self): self.fifo = coro.fifo()
def __init__(self, term): backdoor.__init__(self, term, '\n') self.inlines = coro.fifo()
def subscribe(self): ob = coro.fifo() self.subs.add(ob) return ob
def __init__(self): self.q = coro.fifo() self.subs = set() coro.spawn(self.fanout_thread)
def get_content_gen(self, headers): self.content_fifo = coro.fifo() return self._gen_spdy()
def __init__ (self, term): backdoor.__init__ (self, term, '\n') self.inlines = coro.fifo()
def log (subject, *data): W ('log: %s %r\n' % (subject, data)) G = GlobalState() p = argparse.ArgumentParser (description='Pull a copy of the blockchain from another node.') p.add_argument ('connect', help="connect to this address", metavar='IP:PORT') p.add_argument ('-i', '--inflight', help='number of blocks in flight.', type=int, default=20) p.add_argument ('-b', '--base', help='data directory', default='/usr/local/caesure', metavar='PATH') p.add_argument ('-g', '--getblocks', action='store_true', help='use getblocks rather than getheaders') G.args = p.parse_args() G.args.packet = False G.log = log G.verbose = False G.block_db = BlockDB() block_fifo = coro.fifo() # tried to use inverted_semaphore here, couldn't get it to work. in_flight = 0 in_flight_cv = coro.condition_variable() import coro.backdoor coro.spawn (coro.backdoor.serve, unix_path='/tmp/chainpuller.bd') coro.spawn (go, G) coro.spawn (rate_thread) coro.spawn (write_thread) coro.event_loop()
def __init__ (self, channel, tag): self.channel = channel self.tag = tag self.fifo = coro.fifo() self.closed = False
def subscribe (self): ob = coro.fifo() self.subs.add (ob) return ob
def __init__ (self): self.q = coro.fifo() self.subs = set() coro.spawn (self.fanout_thread)