Advertisement
Guest User

Untitled

a guest
Apr 18th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. inp = [self.sock, pygame.event.get]
  2. out = [self.server]
  3. i, o, x = select.select( inp, out, [] )
  4.  
  5. class SocketListener(threading.Thread):
  6. def __init__(self, sock, queue):
  7. self.daemon = True
  8. self.socket = sock
  9. self.queue = queue
  10. threading.Thread.__init__(self)
  11. def run(self):
  12. while True:
  13. msg = self.socket.recv()
  14. self.queue.put(msg)
  15. class PygameHandler(threading.Thread):
  16. def __init__(self, queue):
  17. self.queue = queue
  18. self.daemon = true
  19. threading.Thread.__init__(self)
  20. def run(self):
  21. while True:
  22. self.queue.put(pygame.event.wait())
  23. queue = Queue.Queue()
  24. PygameHandler(queue).start()
  25. SocketListener(queue).start()
  26. while True:
  27. event = queue.get()
  28. """Process the event()"""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement