Skip to content

Commit

Permalink
fileinstall: remove asyncio logic
Browse files Browse the repository at this point in the history
* Rose will now take over the role of managing its event loop.
* Addresses cylc#274
  • Loading branch information
oliver-sanders committed Feb 20, 2024
1 parent a90198c commit f28922b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions cylc/rose/fileinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ def rose_fileinstall(
config_tree = rose_config_tree_loader(rundir, opts)

if any(i.startswith('file') for i in config_tree.node.value):
startpoint = None
try:
startpoint = os.getcwd()
os.chdir(rundir)
except FileNotFoundError as exc:
raise exc
else:
# Carry out imports.
import asyncio

from metomi.rose.config_processor import ConfigProcessorsManager
from metomi.rose.fs_util import FileSystemUtil
from metomi.rose.popen import RosePopener
Expand All @@ -64,19 +63,11 @@ def rose_fileinstall(
fs_util = FileSystemUtil(event_handler)
popen = RosePopener(event_handler)

# Get an Asyncio loop if one doesn't exist:
# Rose may need an event loop to invoke async interfaces,
# doing this here incase we want to go async in cylc-rose.
# See https://github.com/cylc/cylc-rose/pull/130/files
try:
asyncio.get_event_loop()
except RuntimeError:
asyncio.set_event_loop(asyncio.new_event_loop())

# Process fileinstall.
config_pm = ConfigProcessorsManager(event_handler, popen, fs_util)
config_pm(config_tree, "file")
finally:
os.chdir(startpoint)
if startpoint:
os.chdir(startpoint)

return config_tree.node

0 comments on commit f28922b

Please sign in to comment.