multithreading - Trying to receive messages from a publish/subscribe socket in the background with Python -
i'm working on tank battle ai , such, i'm trying create function updates map , player information in background receiving messages socket pub/sub formal-pattern.
comm communication object in main client.
this movement_strategy() function called module, keep getting error:
exception in thread thread-1, zmqerror: socket operation on non-socket.
any ideas on what's causing or how fix it?
import communication import gamestate import json import threading import time def movement_strategy(comm): def get_gamestate(): [token, msg] = comm.pub_socket.recv_multipart() msg = json.loads(msg) if msg["comm_type"] == "gamestate": game_info = gamestate.gamestate( msg["comm_type"], msg["timestamp"], msg["timeremaining"], msg["map"], msg["players"] ) print game_info.timeremaining print game_info.timestamp time.sleep(1) thread = threading.thread(target=get_gamestate, args()) thread.start()
Comments
Post a Comment