Hi everyone.
I am programming a game using pygame. I intend to control one of the characters using OpenSoundControl (OSC), a udp-based protocol for realtime communication. Basically I am using simpleOSC module to biund some OSC commands to functions on my pygame program.
My game structure is something like this (this is a simplification so you get the idea):
globalsomething = {}
def handler(*m):
global globalsomething
print "it works"
print globalsomething
print "not working"
if __name__ == "__main__":
osc.init()
osc.listen('', 3333)
osc.bind(handler,'/game/dosmtng')
app = Game()
while True:
app.MainLoop()
Game is a simple class that executes pygame.init() and draws and does pretty much everything related to pygame.
The problem I get when executing the code is that when I send an osc packet I get "It works" but not "not working" and then no subsequent osc packets are processed.
Since simpleOSC uses threads, my only explanation to this behavior is that pygame uses some kind of incompatible threading (?) and when trying to access to a variable located in pygame's thread it locks.
Any ideas about the cause and (if possible) a solution?