MCPcopy Index your code
hub / github.com/pgadmin-org/pgadmin4 / execute

Function execute

web/pgadmin/misc/bgprocess/process_executor.py:305–399  ·  view source on GitHub ↗

This function will execute the background process Returns: None

(argv)

Source from the content-addressed store, hash-verified

303
304
305def execute(argv):
306 """
307 This function will execute the background process
308
309 Returns:
310 None
311 """
312 command = argv[1:]
313 args = dict()
314 _log('Initialize the process execution: {0}'.format(command))
315
316 # Create seprate thread for stdout and stderr
317 process_stdout = ProcessLogger('out')
318 process_stderr = ProcessLogger('err')
319
320 try:
321 # update start_time
322 args.update({
323 'start_time': get_current_time(),
324 'stdout': process_stdout.log,
325 'stderr': process_stderr.log,
326 'pid': os.getpid()
327 })
328
329 # Update start time
330 update_status(**args)
331 _log('Status updated...')
332
333 if os.environ.get(os.environ.get('PROCID', None), None):
334 os.environ['PGPASSWORD'] = os.environ[os.environ['PROCID']]
335
336 kwargs = dict()
337 kwargs['close_fds'] = False
338 kwargs['shell'] = False
339 if _IS_WIN:
340 kwargs['creationflags'] = subprocess.CREATE_NO_WINDOW
341
342 # We need environment variables & values in string
343 kwargs['env'] = os.environ.copy()
344
345 _log('Starting the command execution...')
346 process = Popen(
347 command, stdout=PIPE, stderr=PIPE, stdin=None, **kwargs
348 )
349 args.update({
350 'start_time': get_current_time(),
351 'stdout': process_stdout.log,
352 'stderr': process_stderr.log,
353 'pid': process.pid
354 })
355 update_status(**args)
356 _log('Status updated after starting child process...')
357
358 _log('Attaching the loggers to stdout, and stderr...')
359 # Attach the stream to the process logger, and start logging.
360 process_stdout.attach_process_stream(process, process.stdout)
361 process_stdout.start()
362 process_stderr.attach_process_stream(process, process.stderr)

Callers 1

Calls 13

attach_process_streamMethod · 0.95
releaseMethod · 0.95
_logFunction · 0.85
ProcessLoggerClass · 0.85
update_statusFunction · 0.85
_fetch_execute_outputFunction · 0.85
startMethod · 0.80
joinMethod · 0.80
get_current_timeFunction · 0.70
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected