Skip to content

Commit 4a30aba

Browse files
author
David Erb
committed
fixes context and better comments in direct_poll
1 parent f8cd838 commit 4a30aba

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/rockingester_lib/collectors/context.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,21 @@ async def aenter(self) -> None:
6262
await self.server.activate()
6363

6464
# ----------------------------------------------------------------------------------------
65-
async def aexit(self, type, value, traceback) -> None:
65+
async def aexit(self, type=None, value=None, traceback=None):
6666
"""
6767
Asyncio context exit.
6868
6969
Stop service if one was started and releases any client resources.
7070
"""
71+
logger.debug(f"[DISSHU] {thing_type} aexit")
7172

7273
if self.server is not None:
7374
if self.context_specification.get("start_as") == "process":
74-
# Put in request to shutdown the server.
75-
await self.server.client_shutdown()
75+
# The server associated with this context is running?
76+
if await self.is_process_alive():
77+
logger.debug(f"[DISSHU] {thing_type} calling client_shutdown")
78+
# Put in request to shutdown the server.
79+
await self.server.client_shutdown()
7680

7781
if self.context_specification.get("start_as") == "coro":
7882
await self.server.direct_shutdown()

src/rockingester_lib/collectors/direct_poll.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ async def tick(self) -> None:
183183
# ----------------------------------------------------------------------------------------
184184
async def scrape_plates_directories(self) -> None:
185185
"""
186-
Scrape all the configured directories looking for new files.
186+
Scrape all the configured directories looking in each one for new plate directories.
187+
188+
Normally there is only one in the configured list of these places where plates arrive.
187189
"""
188190

189191
# TODO: Use asyncio tasks to paralellize scraping plates directories.
@@ -268,10 +270,7 @@ async def scrape_plate_directory(
268270
self.__visits_directory,
269271
)
270272

271-
logger.debug(
272-
f"[CRYERR] for plate_barcode {plate_barcode} crystal_plate_model.error is {crystal_plate_model.error}"
273-
)
274-
273+
# The model has not been marked as being in error?
275274
if crystal_plate_model.error is None:
276275
visit_directory = get_xchem_directory(
277276
self.__visits_directory, crystal_plate_model.visit
@@ -283,8 +282,14 @@ async def scrape_plate_directory(
283282
crystal_plate_model,
284283
visit_directory,
285284
)
285+
286+
# The model has been marked as being in error?
286287
else:
287-
# Remember we "handled" this one.
288+
logger.debug(
289+
f"[ROCKDIR] for plate_barcode {plate_barcode} crystal_plate_model.error is: {crystal_plate_model.error}"
290+
)
291+
# Remember we "handled" this one within the current instance.
292+
# Keeping this list could be obviated if we could move the files out of the plates directory after we process them.
288293
self.__handled_plate_names.append(plate_name)
289294

290295
# ----------------------------------------------------------------------------------------
@@ -318,7 +323,7 @@ async def scrape_plate_directory_if_complete(
318323
if target.is_dir():
319324
# Presumably this is done, so no error but log it.
320325
logger.debug(
321-
f"[ROCKDIR] plate_barcode {plate_directory.name} is apparently already copied to {target}"
326+
f"[ROCKDIR] plate directory {plate_directory.name} is apparently already copied to {target}"
322327
)
323328
self.__handled_plate_names.append(plate_directory.stem)
324329
return

0 commit comments

Comments
 (0)