[Twisted-Python] dumb question on qt4reactor
Kevin Mcintyre
kebin70 at gmail.com
Sat Jul 5 14:35:01 MDT 2014
calling reactor.callLater within qt4reactor in an attempt to async non
webkit work but not seeing expected behavior. Webkit locks while the
callLater function executes.
Any insight appreciated.
Should I move real work into separate reactor and "broker" calls into
qt4reactor/webkit. I have xmlrpc and websocket hooks into browser...but
looking for guidance as to most direct method of brokering calls between
reactors.
Any insight appreciated.
Having a blast using QT browser as a back-end, see demo site
www.athleets.com.
See below for amazon S3 upload worker that I expected to async, but in
qt4reactor does not appear to work as planned.
from pyscewpt import fixed
from pyscewpt.s3 import bucket_util
import boto
from boto.s3.bucket import Bucket
from boto.s3.key import Key
from twisted.internet import defer, reactor
bucket_queue = defer.DeferredQueue()
def upload_worker(data):
print 'macth upload_worker', data
save_match( data['league'], data['twitter'], data['local_file'],
data['meta'], data['profile'])
return len(bucket_queue.pending)
def match_queue(ign=None):
print 'match_queue:', len(bucket_queue.pending),
len(bucket_queue.waiting)
if ign is None or ign >= 2:
print 'requeue:', len(bucket_queue.pending) ,
len(bucket_queue.waiting)
d = bucket_queue.get()
d.addCallback(upload_worker)
d.addBoth(match_queue)
return d
else:
return None
def queue_save_match(queue_dic):
bucket_queue.put(queue_dic)
print 'queue_save_match', len(bucket_queue.pending),
len(bucket_queue.waiting), queue_dic['twitter'] #
if len(bucket_queue.pending) >= 5 and len(bucket_queue.waiting) == 0:
print 'queue drop worker'
reactor.callLater(0,match_queue,None)
def save_match(league, twitter, systemfile, meta, profile):
print 'save_match:', twitter, profile
s3_filename = league + '/' + twitter + '.png'
bucket_util.save_s3(
boto.connect_s3().get_bucket('~bucket'),
s3_filename,
None,
systemfile,
'image/png',
'public-read',
meta + [('yes', False), ('no', False), ('maybe', False),
('profile', profile)]
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140705/e43bad14/attachment.html>
More information about the Twisted-Python
mailing list