Skip to content
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

Re-add runMonitoring #2344

Merged
merged 9 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ganga/GangaCore/Core/MonitoringComponent/MonitoringService.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,28 @@ def stop(self):
log.error(err)
self._cleanup_scheduled_tasks()
self.loop.call_soon_threadsafe(self.loop.stop)

def runMonitoring(self, jobs=None):
"""
Enable/Run the monitoring loop and wait for the monitoring steps completion.
Parameters:
steps: number of monitoring steps to run
timeout: how long to wait for monitor steps termination (seconds)
jobs: a registry slice to be monitored (None -> all jobs)
Return:
False, if the loop cannot be started or the timeout occured while waiting for monitoring termination
True, if the monitoring steps were successfully executed
Note:
This method is meant to be used in Ganga scripts to request monitoring on demand.
"""

log.debug("runMonitoring")
if not self.alive:
log.error("Cannot run the monitoring loop. It has already been stopped")
return False

self.enabled = True
mesmith75 marked this conversation as resolved.
Show resolved Hide resolved
self.thread_executor = ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE)
self._cleanup_dirty_jobs()
self.loop.call_soon_threadsafe(functools.partial(self._check_active_backends, jobs))
return True
2 changes: 1 addition & 1 deletion ganga/GangaCore/Core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ def bootstrap(reg_slice, interactive_session, my_interface=None):
import GangaCore.GPI
my_interface = GangaCore.GPI

exportToInterface(my_interface, 'runMonitoring', monitoring_component.enable, 'Functions')
exportToInterface(my_interface, 'runMonitoring', monitoring_component.runMonitoring, 'Functions')
Loading