steam icon indicating copy to clipboard operation
steam copied to clipboard

Useless check or Waste of time

Open knkitten opened this issue 4 years ago • 3 comments

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?

knkitten avatar Nov 22 '21 14:11 knkitten

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

rossengeorgiev avatar Nov 22 '21 20:11 rossengeorgiev

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

knkitten avatar Nov 23 '21 19:11 knkitten

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.

rossengeorgiev avatar Nov 23 '21 19:11 rossengeorgiev