Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Get proxy strings from each child process
Pass proxy strings to parent process and use it for import_parallel() call
"""
from .http_transport import ExaSQLImportThread
if import_params is None:
import_params = {}
if 'format' in import_params:
compression = False
else:
compression = self.options['compression']
# There is no need to run separate thread here, all work is performed in child processes
# We simply reuse thread class to keep logic in one place
sql_thread = ExaSQLImportThread(self, exa_proxy_list, compression, table, import_params)
sql_thread.run_sql()
if import_params is None:
import_params = {}
if 'format' in import_params:
compression = False
else:
compression = self.options['compression']
if not callable(callback):
raise ValueError('Callback argument is not callable')
try:
http_proc = ExaHTTPProcess(self.ws_host, self.ws_port, compression, self.options['encryption'], HTTP_IMPORT)
http_proc.start()
sql_thread = ExaSQLImportThread(self, http_proc.get_proxy(), compression, table, import_params)
sql_thread.set_http_proc(http_proc)
sql_thread.start()
result = callback(http_proc.write_pipe, src, **callback_params)
http_proc.write_pipe.close()
http_proc.join()
sql_thread.join()
return result
except Exception as e:
# Close HTTP Server if it is still running
if 'http_proc' in locals():
http_proc.terminate()
# Give higher priority to SQL thread exception