This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from application import log | |
from functools import partial | |
from optparse import OptionParser | |
from twisted.internet import reactor | |
from twisted.words.protocols.jabber.jid import JID | |
from wokkel.client import DeferredClientFactory, clientCreator | |
from wokkel.disco import DiscoClientProtocol | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cb(handle): | |
print("%r, closed=%s" % (handle, handle.closed)) | |
loop.walk(cb) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A multi-producer, multi-consumer queue.""" | |
from collections import deque | |
from time import time as _time | |
from pyuv import thread as _thread | |
__all__ = ['Empty', 'Full', 'Queue'] | |
class Empty(Exception): | |
"Exception raised by Queue.get(block=0)/get_nowait()." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from threading import Thread | |
from time import sleep | |
n_items = 1000 | |
queue = None | |
def put_stuff(): | |
for x in xrange(n_items): | |
queue.put_nowait("xxx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
class WorkItem(object): | |
def __init__(self, func, *args, **kwargs): | |
self.func = func | |
self.args = args | |
self.kwargs = kwargs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _WorkItem(object): | |
def __init__(self, future, fn, args, kwargs): | |
self.future = future | |
self.fn = fn | |
self.args = args | |
self.kwargs = kwargs | |
def run(self): | |
if not self.future.set_running_or_notify_cancel(): | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Form implementation generated from reading ui file 'test.ui' | |
# | |
# Created: Tue Nov 20 17:41:14 2012 | |
# by: PyQt4 UI code generator 4.9.3 | |
# | |
# WARNING! All changes made in this file will be lost! | |
from PyQt4 import QtCore, QtGui |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from greenlet import getcurrent | |
__all__ = ['local'] | |
def _get_local_dict(): | |
current = getcurrent() | |
s = '_%s__local_dict__' % current.__class__.__name__ | |
if not hasattr(current, s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyuv | |
import signal | |
import socket | |
class SignalWaker(object): | |
def __init__(self): | |
# Based on Zope async.py: http://svn.zope.org/zc.ngi/trunk/src/zc/ngi/async.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyuv | |
N = 1000000 | |
def idle_cb(handle): | |
handle.count += 1 | |
if handle.count == N: | |
handle.loop.stop() |