flyingcircusio / batou

batou is a universal, fractal deployment utility using Python.
https://batou.readthedocs.org
Other
47 stars 12 forks source link

Better error message if batou is already running #446

Open frlan opened 3 months ago

frlan commented 3 months ago

I was running a deployment in shell 1 and wanted to start a second one in shell 2

./batou deploy -P production
batou/2.4.1 (cpython 3.11.8-final0, Darwin 23.4.0 arm64)
Could not acquire lock .batou-lock
Traceback (most recent call last):
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/utils.py", line 71, in locked
    fcntl.lockf(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
BlockingIOError: [Errno 35] Resource temporarily unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/me/myprj/./.appenv/a2ac3148/bin/batou", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/main.py", line 221, in main
    return args.func(**func_args)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/deploy.py", line 364, in main
    with locked(".batou-lock"):
  File "/Users/flanitz/.nix-profile/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/Users/me/myprj/.appenv/a2ac3148/lib/python3.11/site-packages/batou/utils.py", line 74, in locked
    raise RuntimeError(
RuntimeError: ('cannot create lock "<_io.TextIOWrapper name=\'.batou-lock\' mode=\'a+\' encoding=\'UTF-8\'>": more than one instance running concurrently?', <_io.TextIOWrapper name='.batou-lock' mode='a+' encoding='UTF-8'>)