ValvePython / steam

☁️ Python package for interacting with Steam
http://steam.readthedocs.io
MIT License
1.05k stars 127 forks source link

Useless check or Waste of time #378

Open knkitten opened 2 years ago

knkitten commented 2 years ago

In file https://github.com/ValvePython/steam/blob/0a6d152e514f0f0cfd8f8e17a8d86341e85aff23/steam/client/__init__.py#L484 in method called login on line 569 we can see a useless check:

if resp and resp.body.eresult == EResult.OK:
    self.sleep(0.5)

this is useless because it is followed by a return string of this method:

return EResult(resp.body.eresult) if resp else EResult.Fail

And why we spend exactly 0.5 seconds, why, for example, not 0.25 or even 1 second?

rossengeorgiev commented 2 years ago

That is hack to allow a couple of async events to run before the functions returns. Could potentially be improved

knkitten commented 2 years ago

@rossengeorgiev Can you give an example of when this hack starts to work? My primitive tests show that this line can be safely removed.

rossengeorgiev commented 2 years ago

According to the origin commit 9ef8e5d9521f19188f80630087ece3738df2f63f it is to allow the client to be considered fully connected (on the backend i guess). I was getting disconnected when I tried to send message immediately after login() returned.