i can't use "self" because that might collide with other threads so i think each thread needs its own class or dictionary to keep variables in.
does CPython do locks between threads to access dictionaries? i haven't seen anything to suggest that it does. since Queues are described as having such locks, i suspect nothing else does unless it says it does, so i think i need to keep things separated between threads.
what about defining these action functions inside the function that needs to call them and have it call like this:
does CPython do locks between threads to access dictionaries? i haven't seen anything to suggest that it does. since Queues are described as having such locks, i suspect nothing else does unless it says it does, so i think i need to keep things separated between threads.
what about defining these action functions inside the function that needs to call them and have it call like this:
def _agent(): ... def x_foo(): ... # code to run when request "foo" arrives def x_bar(): ... # code to run when request "bar" arrives msg = q.get() req = 'x_'+msg[0] if req in locals(): locals()[req]() # call the function to handle this request
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.