Skip to content

Commit

Permalink
Added a state change fo every sw kill result, changed while loop in a…
Browse files Browse the repository at this point in the history
…sserting the sw state
  • Loading branch information
vrbanecd committed Jan 16, 2025
1 parent 710bea5 commit f7a5ef0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions teapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,14 @@ async def _stop_webdav_instance(username, state, condition):
) # GitHub Issue #30
kill_exit_code = kill_proc.wait()
if kill_exit_code != 0:
logger.info("could not kill process with PID %d.", pid)
logger.warning("could not kill process with PID %d.", pid)
exit_code = kill_exit_code
async with condition:
if state[username] == "STOPPING":
state[username] = "RUNNING"
condition.notify()
else:
logger.info("Successfully killed process with PID %d.", pid)
logger.debug("Successfully killed process with PID %d.", pid)
exit_code = 0
async with condition:
if state[username] == "STOPPING":
Expand Down Expand Up @@ -758,21 +762,19 @@ async def storm_webdav_state(state, condition, user):
logger.info(
"Currently, there is no storm webdav instance running for user %s", user
)
while True:
while not (state[user] == "NOT RUNNING" or state[user] == "RUNNING"):
if state[user] == "NOT_RUNNING":
state[user] = "STARTING"
condition.notify()
logger.info("Storm webdav instance for user %s is starting now.", user)
should_start_sw = True
break

elif state[user] == "RUNNING":
async with app.state.state_lock:
app.state.session_state[user]["last_accessed"] = str(
datetime.datetime.now()
)
should_start_sw = False
break
else:
await condition.wait()

Expand All @@ -793,7 +795,7 @@ async def storm_webdav_state(state, condition, user):
"last_accessed": str(datetime.datetime.now()),
}
logger.error(
"something went wrong while starting instance for user %s.",
"Something went wrong while starting instance for user %s.",
user,
)
return -1
Expand All @@ -809,6 +811,7 @@ async def storm_webdav_state(state, condition, user):
"created_at": datetime.datetime.now(),
"last_accessed": str(datetime.datetime.now()),
}
logger.info("StoRM-WebDAV instance for user %s is now running on port %d", user, port)
return port

else:
Expand Down

0 comments on commit f7a5ef0

Please sign in to comment.