mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Attempt to fix timeout issue on Travis. (#16979)
* Attempt to fix timeout issue on Travis.
* Revert "Attempt to fix timeout issue on Travis."
This reverts commit a4e399efab.
* Attempt 2: asyncio galore.
* Guess we don't get to use 3.6
* Guess we don't get to use 3.5
* Dumb mistakes galore
* How did I even manage this?
* Guess we don't get to use 3.4.4
* Hey it works, reduce verbosity a bit.
* asyncio.coroutine.
Technically not needed since asyncio can do without and just screams into a logger if you don't.
* Even less verbose. Shouldn't trigger anymore except for problem cases.
This commit is contained in:
committed by
DamianX
parent
e494afc0fd
commit
bea08be081
@@ -1,15 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function, unicode_literals
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import re
|
||||
import asyncio
|
||||
import distutils.spawn
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
try:
|
||||
import subprocess32 as subprocess
|
||||
except ImportError:
|
||||
import subprocess
|
||||
MAP_INCLUDE_RE = re.compile(r"#include \"maps\\[a-zA-Z0-9][a-zA-Z0-9_]*\.dm\"")
|
||||
|
||||
ensure_future = None
|
||||
|
||||
# ensure_future is new in 3.4.4, previously it was asyncio.async.
|
||||
try:
|
||||
ensure_future = asyncio.ensure_future
|
||||
except AttributeError:
|
||||
# Can't directly do asyncio.async because async is a keyword now,
|
||||
# and that'd parse error on newer versions.
|
||||
ensure_future = getattr(asyncio, "async")
|
||||
|
||||
|
||||
def main():
|
||||
@@ -23,18 +29,17 @@ def main():
|
||||
# Handle map file replacement.
|
||||
with open(dme, "r") as f:
|
||||
content = f.read()
|
||||
|
||||
|
||||
# Make string to replace the map include with.
|
||||
includes = ""
|
||||
for arg in args.mapfile:
|
||||
includes += "#include \"maps\\\\{}.dm\"\n".format(arg)
|
||||
|
||||
MAP_INCLUDE_RE = re.compile(r"#include \"maps\\[a-zA-Z0-9][a-zA-Z0-9_]*\.dm\"")
|
||||
|
||||
content = MAP_INCLUDE_RE.sub(includes, content, count=1)
|
||||
dme = "{}.mdme".format(dme)
|
||||
with open(dme, "w") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
compiler = "DreamMaker"
|
||||
if sys.platform == "win32" or sys.platform == "cygwin":
|
||||
compiler = "dm"
|
||||
@@ -44,8 +49,28 @@ def main():
|
||||
print("Unable to find DM compiler.")
|
||||
exit(1)
|
||||
|
||||
code = subprocess.call([compiler, dme])
|
||||
loop = asyncio.get_event_loop()
|
||||
code = loop.run_until_complete(run_compiler([compiler, dme]))
|
||||
exit(code)
|
||||
|
||||
# DM SOMEHOW manages to go 10 minutes without logging anything nowadays.
|
||||
# So... Travis kills it.
|
||||
# Thanks DM.
|
||||
# This repeats messages like travis_wait (which I couldn't get working) does to prevent that.
|
||||
@asyncio.coroutine
|
||||
def run_compiler(args):
|
||||
compiler_process = yield from asyncio.create_subprocess_exec(*args)
|
||||
task = ensure_future(print_timeout_guards())
|
||||
|
||||
ret = yield from compiler_process.wait()
|
||||
task.cancel()
|
||||
return ret
|
||||
|
||||
@asyncio.coroutine
|
||||
def print_timeout_guards():
|
||||
while True:
|
||||
yield from asyncio.sleep(8*60)
|
||||
print("Keeping Travis alive. Ignore this!")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user