[Tutor] multi processes or threads?
alan.gauld at btinternet.com
Mon Sep 3 19:41:40 CEST 2012
On 03/09/12 15:04, richard kappler wrote:
> what I'm looking for. The bot would have several "threads" running
> concurrently so as to be aware of it's state, such as a vision thread,
> an object and face recognition thread, a chat thread, a command and
> control thread, a nav thread, you get the idea. In order to do this in
> python, should I be looking at threads, multiprocessing, something else
> or is this not practicable in python?
Threads. Multiple processes would be overkill for this.
And yes its fine in Python. Check out the threading module.
Several online tutorials on how to use it too.
My only caveat is not to have too many, especially
conflicting controls. For example anything that causes the bot to move
should be in a single thread or you wind up with two threads competing
with each other to move the bot in two directions at once. Similarly
vision and face recognition could conflict.
Hopefully you get my drift.
Author of the Learn to Program web site
More information about the Tutor