R
Railway•4mo 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•4mo ago
Project ID: 316b545c-54be-4dbc-a060-bd5b8345755a
m1rza
m1rza•4mo 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
m1rza•4mo ago
This is the output with a literally TimeUnit.SECONDS.sleep(1);
No description
Solution
m1rza
m1rza•4mo 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.