ValvePython / csgo

🔫 Python package for interacting with CS:GO Game Coordinator
http://csgo.readthedocs.io
124 stars 17 forks source link

Waiting on a job id doesn't seem to yield results #10

Closed jamezmoran closed 7 years ago

jamezmoran commented 7 years ago

I'm trying to send a request off as a job, but when I try to wait on the job id, it just blocks until the timeout expires yielding a None response. I've used the player profile request as an example here in the below reproducer. Changing the job id to 'player_profile' works and returns a profile, however this isn't suitable for my application as I need to be able to forward the correct response back to the original requester, and there may be many requesters at the same time. Am I doing this incorrectly, or is this unexpected behaviour? I've posted a reproducer below.

Thanks

from steam import SteamClient
from csgo import CSGOClient
from csgo.enums import ECsgoGCMsg

client = SteamClient()
cs = CSGOClient(client)

@client.on('logged_on')
def start_csgo():
    cs.launch()

@cs.on('ready')
def ready(*args, **kwargs):
  jobid = cs.send_job(ECsgoGCMsg.EMsgGCCStrike15_v2_ClientRequestPlayersProfile, {
    'account_id': cs.account_id,
    'request_level': 32,
  })
  resp = cs.wait_msg(jobid, timeout=10)
  print(resp)

client.login(username='yourusername', password='yourpassword')
client.run_forever()
rossengeorgiev commented 7 years ago

Because that message is not a job. See here https://github.com/ValvePython/csgo/blob/4024625fe347ac0aadd5b2222e66af71ede1f5cc/csgo/features/player.py#L78-L96

http://csgo.readthedocs.io/en/stable/csgo.features.player.html

jamezmoran commented 7 years ago

@rossengeorgiev as mentioned above, I'm not using the request_player_profile method as it doesn't provide a way to identify the original requester when used in a multithreaded environment. Are you saying that there are some messages that will work as jobs, and others that will not? Where might I find a reference to this? Waiting on an ID is useful since you can have multiple threads making simultaneous requests and blocking on the ID they are given, although I don't know if this library is designed for multiple threads sharing the same client object, but it would seem logical given its async nature.

rossengeorgiev commented 7 years ago

Are you saying that there are some messages that will work as jobs, and others that will not?

Some messages are jobs, other are not. There is no reference.

If you are talking about regular threads, I would avoid that due to gevent. Rate limits on the steam network will also make that not a good idea. You can run multiple SteamClient on a single thread without an issue. Then you can setup some sort of message broker communication to make requests.

rossengeorgiev commented 7 years ago

Closing this due to inactivity.