def main(get_handler): parser = argparse.ArgumentParser() parser.add_argument("--sockname") parser.add_argument("--numproc") parser.add_argument("--version-serial", type=int) args = parser.parse_args() ql_parser.preload(allow_rebuild=False) gc.freeze() if args.numproc is None: # Run a single worker process run_worker(args.sockname, args.version_serial, get_handler) return numproc = int(args.numproc) assert numproc >= 1 # Abort the template process if more than `max_worker_spawns` # new workers are created continuously - it probably means the # worker cannot start correctly. max_worker_spawns = numproc * 2 children = set() continuous_num_spawns = 0 for _ in range(int(args.numproc)): # spawn initial workers if pid := os.fork(): # main process children.add(pid) continuous_num_spawns += 1 else: # child process break
async def start(self): # Make sure that EdgeQL parser is preloaded; edgecon might use # it to restore config values. ql_parser.preload() if self._startup_script: await binary.EdgeConnection.run_script( server=self, database=self._startup_script.database, user=self._startup_script.user, script=self._startup_script.text, ) self._servers = await self._start_servers( self._listen_host, self._listen_port) self._accepting_connections = True self._serving = True if self._echo_runtime_info: ri = { "port": self._listen_port, "runstate_dir": str(self._runstate_dir), } print(f'\nEDGEDB_SERVER_DATA:{json.dumps(ri)}\n', flush=True)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--sockname') parser.add_argument('--numproc') args = parser.parse_args() numproc = int(args.numproc) assert numproc >= 1 # Abort the template process if more than `max_worker_spawns` # new workers are created continuously - it probably means the # worker cannot start correctly. max_worker_spawns = numproc * 2 ql_parser.preload() gc.freeze() children = set() continuous_num_spawns = 0 for _ in range(int(args.numproc)): # spawn initial workers if pid := os.fork(): # main process children.add(pid) continuous_num_spawns += 1 else: # child process break
async def run_startup_script_and_exit(self): """Run the script specified in *startup_script* and exit immediately""" if self._startup_script is None: raise AssertionError('startup script is not defined') ql_parser.preload() await self._mgmt_port.run_startup_script_and_exit() return
def _init_parsers(): # Initialize all parsers, rebuilding grammars if # necessary. Do it earlier than later so that we don't # end up in a situation where all our compiler processes # are building parsers in parallel. from edb.edgeql import parser as ql_parser ql_parser.preload()
async def run_startup_script_and_exit(self): """Run the script specified in *startup_script* and exit immediately""" if self._startup_script is None: raise AssertionError('startup script is not defined') ql_parser.preload() await binary.EdgeConnection.run_script( server=self, database=self._startup_script.database, user=self._startup_script.user, script=self._startup_script.text, ) return
async def run_startup_script_and_exit(self): """Run the script specified in *startup_script* and exit immediately""" if self._startup_script is None: raise AssertionError('startup script is not defined') await self._create_compiler_pool() try: ql_parser.preload() await binary.EdgeConnection.run_script( server=self, database=self._startup_script.database, user=self._startup_script.user, script=self._startup_script.text, ) finally: await self._destroy_compiler_pool()
async def start(self): # Make sure that EdgeQL parser is preloaded; edgecon might use # it to restore config values. ql_parser.preload() async with taskgroup.TaskGroup() as g: g.create_task(self._mgmt_port.start()) for port in self._ports: g.create_task(port.start()) sys_config = self._dbindex.get_sys_config() if 'ports' in sys_config: for portconf in sys_config['ports']: await self._start_portconf(portconf, suppress_errors=True) self._serving = True
async def start(self): self._stop_evt.clear() assert self._task_group is None self._task_group = taskgroup.TaskGroup() await self._task_group.__aenter__() self._accept_new_tasks = True await self._create_compiler_pool() # Make sure that EdgeQL parser is preloaded; edgecon might use # it to restore config values. ql_parser.preload() if self._startup_script: await binary.EdgeConnection.run_script( server=self, database=self._startup_script.database, user=self._startup_script.user, script=self._startup_script.text, ) self._servers, actual_port, listen_addrs = await self._start_servers( _fix_wildcard_host(self._listen_hosts), self._listen_port) if self._listen_port == 0: self._listen_port = actual_port self._accepting_connections = True self._serving = True if self._echo_runtime_info: ri = { "port": self._listen_port, "runstate_dir": str(self._runstate_dir), "tls_cert_file": self._tls_cert_file, } print(f'\nEDGEDB_SERVER_DATA:{json.dumps(ri)}\n', flush=True) if self._status_sink is not None: status = { "listen_addrs": listen_addrs, "port": self._listen_port, "socket_dir": str(self._runstate_dir), "main_pid": os.getpid(), "tenant_id": self._tenant_id, "tls_cert_file": self._tls_cert_file, } self._status_sink(f'READY={json.dumps(status)}')
def main(): parser = argparse.ArgumentParser() parser.add_argument('--sockname') parser.add_argument('--numproc') args = parser.parse_args() numproc = int(args.numproc) assert numproc > 1 ql_parser.preload() gc.freeze() for _ in range(int(args.numproc) - 1): if not os.fork(): # child process break try: run_worker(args.sockname) except (amsg.PoolClosedError, KeyboardInterrupt): exit(0)
async def start(self): # Make sure that EdgeQL parser is preloaded; edgecon might use # it to restore config values. ql_parser.preload() async with taskgroup.TaskGroup() as g: g.create_task(self._mgmt_port.start()) for port in self._ports: g.create_task(port.start()) sys_config = self._dbindex.get_sys_config() if 'ports' in sys_config: for portconf in sys_config['ports']: await self._start_portconf(portconf, suppress_errors=True) self._serving = True if self._echo_runtime_info: ri = { "port": self._mgmt_port_no, "runstate_dir": str(self._runstate_dir), } print(f'\nEDGEDB_SERVER_DATA:{json.dumps(ri)}\n', flush=True)
async def start(self): # Make sure that EdgeQL parser is preloaded; edgecon might use # it to restore config values. ql_parser.preload() if self._startup_script: await binary.EdgeConnection.run_script( server=self, database=self._startup_script.database, user=self._startup_script.user, script=self._startup_script.text, ) self._servers, actual_port = await self._start_servers( self._listen_host, self._listen_port) if self._listen_port == 0: self._listen_port = actual_port self._accepting_connections = True self._serving = True if self._echo_runtime_info: ri = { "port": self._listen_port, "runstate_dir": str(self._runstate_dir), } print(f'\nEDGEDB_SERVER_DATA:{json.dumps(ri)}\n', flush=True) if self._status_sink is not None: status = { "port": self._listen_port, "socket_dir": str(self._runstate_dir), "main_pid": os.getpid(), "tenant_id": self._tenant_id, } self._status_sink(f'READY={json.dumps(status)}')
def main(): parser = argparse.ArgumentParser() parser.add_argument('--sockname') parser.add_argument('--numproc') args = parser.parse_args() numproc = int(args.numproc) assert numproc > 1 ql_parser.preload() gc.freeze() children = set() continuous_num_spawns = 0 for _ in range(int(args.numproc)): # spawn initial workers if pid := os.fork(): # main process children.add(pid) continuous_num_spawns += 1 else: # child process break
def run_test_cases_setup(setup: TestCasesSetup, jobs: int) -> None: qlparser.preload( parsers=setup.parsers, allow_rebuild=True, paralellize=jobs > 1, )