Paused time and local network I/O #7237
-
The documentation for tokio::time::pause says,
It doesn't exactly say what work is, but
Now I have a test that sends some requests to a network server on localhost, using What is happening? Does network I/O not count as "work"? If not, is there any way to make this test work reliably with paused time? (I guess I could create a blocking task, just during the request, to prevent auto-advancing the clock, but that would be a pretty weird hack.) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Looking at the code, auto advance is checked in the parking logic in the worker thread (code), so I think waiting a network IO could trigger the auto-advance. |
Beta Was this translation helpful? Give feedback.
-
If you run the client and server on the same Tokio runtime, then the work performed by the server will count as work and prevent auto-advance. Paused time cannot be reliably used with external servers. |
Beta Was this translation helpful? Give feedback.
If you run the client and server on the same Tokio runtime, then the work performed by the server will count as work and prevent auto-advance. Paused time cannot be reliably used with external servers.