3. Object-oriented wrapper¶
-
class
doloop.
DoLoop
(dbconn, table)¶ A very thin wrapper that stores connection and table name, so you don’t have have to specify dbconn and table over and over again.
For example:
foo_loop = doloop.DoLoop(dbconn, 'foo_loop') foo_ids = foo_loop.get(100) for foo_id in foo_ids: # update foo_id ... foo_loop.did(foo_ids)
-
DoLoop.
__init__
(dbconn, table)¶ Wrap a task loop table in an object
Parameters: - dbconn – any DBI-compliant MySQL connection object, or a callable that returns one. If you use a callable, it’ll be called every time a method is called on this object, so put any caching/pooling/etc. inside your callable.
- table (string) – name of your task loop table
You can read (but not change) the table name from
self.table
-
DoLoop.
remove
(id_or_ids, updated=False, test=False)¶ Remove IDs from this task loop.
See
remove()
for details.
-
DoLoop.
get
(limit, lock_for=3600, min_loop_time=3600, test=False)¶ Get some IDs of things to update and lock them.
See
get()
for details.
-
DoLoop.
did
(id_or_ids, auto_add=True, test=False)¶ Mark IDs as updated and unlock them.
See
did()
for details.
-
DoLoop.
unlock
(id_or_ids, auto_add=True, test=False)¶ Unlock IDs without marking them updated.
See
unlock()
for details.