예제 #1
0
def enable_remote_debugging():
    try:
        import pystuck

        pystuck.run_server()
    except ImportError:
        logger.error("No socket opened for debugging -> please install pystuck")
예제 #2
0
def init_process(verbose, start_pystuck, rm):
    if start_pystuck:
        import pystuck
        pystuck.run_server(port=((os.getpid() % 10000) + 10001))

    global request_manager
    request_manager = rm
예제 #3
0
def install_pystuck():
	import pystuck
	stuck_port = 6666
	while 1:
		try:
			pystuck.run_server(port=stuck_port)
			print("PyStuck installed to process, running on port %s" % stuck_port)
			return
		except OSError:
			stuck_port += 1
		if stuck_port > 7000:
			raise RuntimeError("wat?")
예제 #4
0
def install_pystuck():
    import pystuck
    stuck_port = 6666
    while 1:
        try:
            pystuck.run_server(port=stuck_port)
            print("PyStuck installed to process, running on port %s" %
                  stuck_port)
            return
        except OSError:
            stuck_port += 1
        if stuck_port > 7000:
            raise RuntimeError("wat?")
예제 #5
0
    def run(self):
        if self.debugport:
            pystuck.run_server(port=self.debugport)

        try:
            with self.running_status():
                self.main_loop()
        except Exception:
            with self.engine.begin() as cn:
                update('rework.worker').where(id=self.wid).values(
                    traceback=traceback.format_exc()).do(cn)
            raise
        except SystemExit as exit:
            raise
예제 #6
0
def go():

    import pystuck
    pystuck.run_server()

    largv = [tmp.lower() for tmp in sys.argv]

    if not "noreset" in largv:
        print("Resetting any in-progress downloads.")
        WebMirror.Runner.resetInProgress()
    else:
        print("Not resetting in-progress downloads.")

    rules = WebMirror.rules.load_rules()
    # WebMirror.Runner.initializeStartUrls(rules)

    global NO_PROCESSES
    global MAX_DB_SESSIONS
    MAX_DB_SESSIONS = NO_PROCESSES + 5

    processes = 16
    NO_PROCESSES = processes
    MAX_DB_SESSIONS = NO_PROCESSES + 5
    if "maxprocesses" in largv:
        processes = 24
        NO_PROCESSES = processes
        MAX_DB_SESSIONS = NO_PROCESSES + 5
    elif "fewprocesses" in largv:
        processes = 8
        NO_PROCESSES = processes
        MAX_DB_SESSIONS = NO_PROCESSES + 5
    elif "twoprocess" in largv:
        processes = 2
        NO_PROCESSES = processes
        MAX_DB_SESSIONS = NO_PROCESSES + 2
    elif "oneprocess" in largv:
        processes = 1
        NO_PROCESSES = processes
        MAX_DB_SESSIONS = NO_PROCESSES + 2

    runner = WebMirror.Runner.Crawler(thread_count=NO_PROCESSES)
    runner.run()
예제 #7
0
def run_from_console():
    # Get command line arguments
    import argparse

    parser = argparse.ArgumentParser(
        prog='ocellaris',
        description='Discontinuous Galerkin Navier-Stokes solver')
    parser.add_argument(
        'inputfile',
        help='Name of file containing simulation '
        'configuration on the Ocellaris YAML input format',
    )
    parser.add_argument(
        '--set-input',
        '-i',
        action='append',
        help='Set an input key. Can be added several '
        'times to set multiple input keys. Example: --set-input time/dt=0.1',
    )

    parser.add_argument(
        '--pystuck',
        action='store_true',
        help='Activate pystuck to debug hangs (only on MPI rank 0)',
    )

    args = parser.parse_args()

    # Enable debuging of stuck processes
    if args.pystuck and dolfin.MPI.comm_world.rank == 0:
        try:
            import pystuck

            pystuck.run_server()
        except Exception as e:
            print('Could not start pystuck')
            print(e)
            print('Starting Ocellaris without pystuck')

    # Run Ocellaris
    main(args.inputfile, args.set_input)
예제 #8
0
import pystuck


pystuck.run_server()

import gevent
def foo():
    gevent.sleep(1)
def foo2():
    pass


gevent.spawn(foo)
gevent.spawn(foo)
gevent.spawn(foo)
gevent.sleep(0.4)
gevent.spawn(foo2)
pystuck.run_client()
예제 #9
0
import pystuck

pystuck.run_server()

import gevent


def foo():
    gevent.sleep(1)


def foo2():
    pass


gevent.spawn(foo)
gevent.spawn(foo)
gevent.spawn(foo)
gevent.sleep(0.4)
gevent.spawn(foo2)
pystuck.run_client()
예제 #10
0
# begin: https://stackoverflow.com/a/45690594/7829525
import socket
from contextlib import closing


def find_free_port():
    with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
        s.bind(('', 0))
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        return s.getsockname()[1]


# end

_port = find_free_port()
print(f"""
    pystuck port: {_port}
""", flush=True)
import pystuck

pystuck.run_server(port=_port)