[hg] galaxy 3385: LIMS: using threads for data transfer. first pass
details: http://www.bx.psu.edu/hg/galaxy/rev/b5786505e278 changeset: 3385:b5786505e278 user: rc date: Fri Feb 12 16:59:57 2010 -0500 description: LIMS: using threads for data transfer. first pass diffstat: lib/galaxy/web/controllers/requests_admin.py | 46 +++++++++++++++++------ scripts/galaxy_messaging/server/data_transfer.py | 4 +- 2 files changed, 34 insertions(+), 16 deletions(-) diffs (94 lines): diff -r 6cbd13376ce8 -r b5786505e278 lib/galaxy/web/controllers/requests_admin.py --- a/lib/galaxy/web/controllers/requests_admin.py Fri Feb 12 16:45:37 2010 -0500 +++ b/lib/galaxy/web/controllers/requests_admin.py Fri Feb 12 16:59:57 2010 -0500 @@ -11,7 +11,7 @@ from sqlalchemy.sql.expression import func, and_ from sqlalchemy.sql import select import pexpect -import ConfigParser +import ConfigParser, threading, time log = logging.getLogger( __name__ ) @@ -204,6 +204,18 @@ action='create_request_type' ) ) ] +class DataTransferThread(threading.Thread): + def __init__(self, **kwargs): + threading.Thread.__init__(self, name=kwargs['name']) + self.dataset_index = kwargs['dataset_index'] + self.cmd = kwargs['cmd'] + def run(self): + try: + retcode = subprocess.call(self.cmd) + except Exception, e: + error_msg = "Data transfer failed. " + str(e) + "<br/>" + log.debug(error_msg) + # # ---- Request Controller ------------------------------------------------------ @@ -1511,7 +1523,7 @@ trans.sa_session.add( dp ) trans.sa_session.flush() return datatx_user - + def __start_datatx(self, trans, sample): # data transfer user datatx_user = self.__setup_datatx_user(trans, sample.library, sample.folder) @@ -1542,20 +1554,28 @@ str(index), trans.security.encode_id(sample.library.id), trans.security.encode_id(sample.folder.id) ) - # set the transfer status +# # set the transfer status sample.dataset_files[index][1] = sample.transfer_status.IN_PROGRESS trans.sa_session.add( sample ) trans.sa_session.flush() - try: - retcode = subprocess.call(cmd) - except Exception, e: - error_msg = dfile.split('/')[-1] + ": Data transfer failed. " + str(e) + "<br/>" - return trans.response.send_redirect( web.url_for( controller='requests_admin', - action='show_datatx_page', - sample_id=trans.security.encode_id(sample.id), - folder_path=os.path.dirname(dfile), - messagetype='error', - msg=error_msg)) + dtt = DataTransferThread(name='thread_'+str(index), + dataset_index=index, + cmd=cmd) + dtt.start() +# # set the transfer status +# sample.dataset_files[index][1] = sample.transfer_status.IN_PROGRESS +# trans.sa_session.add( sample ) +# trans.sa_session.flush() +# try: +# retcode = subprocess.call(cmd) +# except Exception, e: +# error_msg = dfile.split('/')[-1] + ": Data transfer failed. " + str(e) + "<br/>" +# return trans.response.send_redirect( web.url_for( controller='requests_admin', +# action='show_datatx_page', +# sample_id=trans.security.encode_id(sample.id), +# folder_path=os.path.dirname(dfile), +# messagetype='error', +# msg=error_msg)) # set the sample state to the last state if sample.current_state().id != sample.request.type.states[-1].id: event = trans.app.model.SampleEvent(sample, sample.request.type.states[-1], diff -r 6cbd13376ce8 -r b5786505e278 scripts/galaxy_messaging/server/data_transfer.py --- a/scripts/galaxy_messaging/server/data_transfer.py Fri Feb 12 16:45:37 2010 -0500 +++ b/scripts/galaxy_messaging/server/data_transfer.py Fri Feb 12 16:59:57 2010 -0500 @@ -38,9 +38,7 @@ pkg_resources.require( "simplejson" ) import simplejson -curr_dir = os.getcwd() -logfile = os.path.join(os.getcwd(), 'data_transfer.log') -logging.basicConfig(filename=logfile, level=logging.DEBUG, +logging.basicConfig(filename=sys.stderr, level=logging.DEBUG, format="%(asctime)s [%(levelname)s] %(message)s") class DataTransferException(Exception):
participants (1)
-
Greg Von Kuster