Skip to content

Commit

Permalink
puts back datafaces context
Browse files Browse the repository at this point in the history
  • Loading branch information
David Erb committed Apr 20, 2023
1 parent 17d7466 commit aab1378
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
31 changes: 0 additions & 31 deletions src/soakdb3_lib/context.py

This file was deleted.

32 changes: 31 additions & 1 deletion src/soakdb3_lib/datafaces/context.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

# Base class for a Thing which has a name and traits.
from dls_utilpack.callsign import callsign
from dls_utilpack.thing import Thing

# Things created in the context.
Expand All @@ -20,6 +20,8 @@ class Context(Thing):
On exiting, it commands the server to shut down.
The enter and exit methods are exposed for use during testing.
TODO: Add unit test for soakdb3_lib.datafaces.context.
"""

# ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -70,3 +72,31 @@ async def __aexit__(self, type, value, traceback):
""" """

await self.aexit()

# ----------------------------------------------------------------------------------------
async def is_process_started(self):
""""""

if self.server is None:
raise RuntimeError(f"{callsign(self)} a process has not been defined")

try:
return await self.server.is_process_started()
except Exception:
raise RuntimeError(
f"unable to determing process started for server {callsign(self.server)}"
)

# ----------------------------------------------------------------------------------------
async def is_process_alive(self):
""""""

if self.server is None:
raise RuntimeError(f"{callsign(self)} a process has not been defined")

try:
return await self.server.is_process_alive()
except Exception:
raise RuntimeError(
f"unable to determing dead or alive for server {callsign(self.server)}"
)

0 comments on commit aab1378

Please sign in to comment.