-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AsyncBuffer update #130
base: main
Are you sure you want to change the base?
AsyncBuffer update #130
Conversation
ldp/alg/rollout.py
Outdated
@@ -194,12 +194,16 @@ async def _sample_trajectories_from_envs( | |||
self.traj_buffer.clear() | |||
|
|||
traj_ids = [uuid.uuid4().hex for _ in range(len(environments))] | |||
await asyncio.gather( | |||
from tqdm.asyncio import tqdm_asyncio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we import this at the module level?
try: | ||
# Wait for either the batch to fill up or the timeout to expire | ||
await asyncio.wait_for(self._batch_ready_event.wait(), timeout=self.timeout) | ||
except asyncio.TimeoutError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async with asyncio.timeout(self.timeout):
# Wait for either the batch to fill up or the timeout to expire
self._batch_ready_event.wait()
Alternate way of doing this using built-in asyncio.timeout
I am not sure if you need to await
the wait()
await self._processed_events[request_id].wait() | ||
|
||
async with self._lock: | ||
print(f"Finished Request ID: {request_id}, Counter: {self._events_count[request_id]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use logging
not print
self._processed_events[request_id] = asyncio.Event() | ||
self._events_count[request_id] = self._counter | ||
self._counter += 1 | ||
print(f"Started Request ID: {request_id}, Counter: {self._events_count[request_id]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use logging
over print
No description provided.