Q4M operation wrapper
Project description
This module is simple Q4M operation wrapper developed by pixiv Inc. for asynchronous upload system
Simple example of usage is followings
>>> from python_q4m.q4m import * >>> class QueueTable(Q4M): >>> def __init__(self, con): >>> super(self.__class__, self).__init__(con) >>> self.table = 'queue_table' >>> self.columns = ['id', >>> 'msg', >>> ] >>> try: >>> con = MySQLdb.connect(host='localhost', >>> db=dbname, >>> user=username, >>> passwd=password, >>> ) >>> q = QueueTable(con) >>> q.enqueue([1, 'msg']) >>> while q.wait() == 0: >>> time.sleep(1); >>> res = q.dequeue() >>> print res['id'] >>> print res['msg'] >>> q.end() >>> con.close() >>> except MySQLdb.Error, e: >>> print 'Error %d: %s' % (e.args[0], e.args[1]) >>> q.abort() >>> con.close()
And it is necessary to create following table for above example.
CREATE TABLE queue_table (id int(11) NOT NULL, msg text NOT NULL) ENGINE=QUEUE;
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python_q4m-0.0.5.tar.gz
(2.3 kB
view hashes)
Built Distributions
python_q4m-0.0.5-py2.7.egg
(5.1 kB
view hashes)
Close
Hashes for python_q4m-0.0.5.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86b3a4cf27bc2853e9aaa6ceeeb4d66474bbeb1bc0ec43c018061311c63c7a76 |
|
MD5 | fd670328af030eb77f84d7daf9cec51c |
|
BLAKE2b-256 | 3a0c87963d8e1acea38dd139c59fdebbbb93f32dc5f18885d6991f3ade83f2f0 |