concurrency - Running multiple concurrent Python programs accessing the same database table -


is there in python allows run multiple concurrent python programs potentially access same database table , prevent each program using full cpu , thereby allow server have additional capacity left over?

several issues:

  1. multiple concurrent python programs - see http://wiki.python.org/moin/concurrency, start try builtin module multiprocessing (http://docs.python.org/2/library/multiprocessing.html)
  2. access same database table - each process should create own db connection - after concurrency managed by/or configured within rdbms and/or connection/query options. if need sync between processes - using locks/semaphores help.
  3. prevent each program using full cpu - depends processes should do, go with:
    • having 1 main program runs time (master process), pauses (time.sleep, gevent.sleep or similar) , spawns , controls spawned processes (workers)
    • spawned processes job (workers) - open new connection, db actions , quit

i'm sure of workflows/systems provided multiprocessing (or other) modules fit needs (workers, pools, queues, pipes, shared states, synchronization, ...).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -