R
Railway•10mo ago
m1rza

Thread.sleep(...) doesn't work

Before I dive into details, does for any reason Thread.sleep(1000) not work with Railway? PID: 316b545c-54be-4dbc-a060-bd5b8345755a
No description
Solution:
For anyone else, I ended up using WebClient instead of RestTemplate. I tried sleep, empty loops, ServiceExecutor, waiting on objects in sync blocks - no dice. WebClient solves the issue by taking care of the timing for me....
Jump to solution
4 Replies
Percy
Percy•10mo ago
Project ID: 316b545c-54be-4dbc-a060-bd5b8345755a
m1rza
m1rzaOP•10mo ago
I'm making delayed requests to Steam because they don't allow a rate of requests which would theoretically result in over 100k requests in 24 hours. I've put a Thread.sleep(1000) in my API caller and locally it worked just fine. However when deployed it doesn't seem to actually sleep. So I replaced the sleep call with a ScheduledExecutorService which delayes the call for 1 second. Worked just fine locally but again does not seem to work when deployed. Nobody? 😦
m1rza
m1rzaOP•10mo ago
This is the output with a literally TimeUnit.SECONDS.sleep(1);
No description
Solution
m1rza
m1rza•10mo ago
For anyone else, I ended up using WebClient instead of RestTemplate. I tried sleep, empty loops, ServiceExecutor, waiting on objects in sync blocks - no dice. WebClient solves the issue by taking care of the timing for me.
Want results from more Discord servers?
Add your server