Commit 73e97969 authored by dylan grafmyre's avatar dylan grafmyre
Browse files

epoll-then

parent 04418fc7
......@@ -178,10 +178,12 @@ maps/%.bsp: %.bsp
ln -f lua/nav_generate.lua "$(MOD_DIR)/lua/autorun/runme.lua"
$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) \
+sv_cheats 1 +nav_edit 1 +map navgen || true
$(SHLEX_BIN) $(SHLEX_FLAGS) $(EPOLL_THEN_BIN) $(EPOLL_THEN_FLAGS) --literal ng_2 --file "'$(MOD_DIR)/data/runme.txt'" -- \
echo TIME TO DO THINGS &
# todo: check "$(MOD_DIR)/data/runme.txt" for content "ng_f", to trigger kill hl2.exe
+sv_cheats 1 +nav_edit 1 +map navgen &
$(SHLEX_BIN) $(SHLEX_FLAGS) $(EPOLL_THEN_BIN) $(EPOLL_THEN_FLAGS) \
--literal ng_f --file "'$(MOD_DIR)/data/runme.txt'" --timeout-sec 1800 -- \
kill $$!
# ^ watch "$(MOD_DIR)/data/runme.txt" for content "ng_f", when match: kill hl2.exe
# timeout: 30min
cp -v "$(MOD_DIR)/maps/navgen.nav" $@
rm -v \
"$(MOD_DIR)/lua/autorun/runme.lua" \
......
......@@ -16,6 +16,7 @@ ARGP.add_argument('remainder', nargs=argparse.REMAINDER)
ARGP.add_argument('--file', required=True)
ARGP.add_argument('--literal', required=True)
ARGP.add_argument('--poll-sec', type=float, default=2)
ARGP.add_argument('--timeout-sec', type=float)
def main(argp=None, argv=None):
if argp is None:
......@@ -27,6 +28,7 @@ def main(argp=None, argv=None):
level=logging.INFO,
)
start = time.time()
while True:
with open(argp.file) as fh:
dat = fh.read()
......@@ -35,6 +37,10 @@ def main(argp=None, argv=None):
if match:
break
if arp.timeout_sec:
if (time.time() - start) > argp.timeout_sec:
LOGGER.warning('status: match=%s %s=%r', (match, argp.literal), argp.file, dat)
raise TimeoutError('epoll-then timeout')
time.sleep(argp.poll_sec)
if argp.remainder:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment