pikers / piker

(e2e) foss trading for non-tinas
GNU Affero General Public License v3.0
103 stars 17 forks source link

Simplify throttle loop to a single `while` block #242

Closed goodboy closed 2 years ago

goodboy commented 2 years ago

This should in theory result in increased burstiness since we remove the plain trio.sleep() and instead always wait on the receive channel as much as possible until the trio.move_on_after() (+ time diffing calcs) times out and signals the next throttled send cycle. This also is slightly easier to grok code-wise instead of the try, except and another tight while loop until a trio.WouldBlock. The only simpler way i can think to do it is with 2 tasks: 1 to collect ticks and the other to read and send at the throttle rate.