Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:21

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0OA
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2024
0010 
0011 
0012 import inspect     # noqa F401
0013 import logging     # noqa F401
0014 import os          # noqa F401
0015 import shutil      # noqa F401
0016 import sys         # noqa F401
0017 
0018 # from nose.tools import assert_equal
0019 from idds.common.utils import setup_logging
0020 
0021 from idds.iworkflow.asyncresult import AsyncResult
0022 from idds.iworkflow.workflow import Workflow       # workflow
0023 
0024 setup_logging(__name__)
0025 # setup_logging(__name__, loglevel='debug')
0026 # logging.getLogger('stomp').setLevel(logging.DEBUG)
0027 
0028 
0029 def test_workflow():
0030     print("test workflow starts")
0031     print('idds')
0032     print("test workflow ends")
0033 
0034 
0035 if __name__ == '__main__':
0036 
0037     wf = Workflow(func=test_workflow, service='idds')
0038 
0039     workflow_context = wf._context
0040 
0041     logging.info("Test AsyncResult")
0042     a_ret = AsyncResult(workflow_context, wait_num=1, timeout=30)
0043     a_ret.subscribe()
0044 
0045     async_ret = AsyncResult(workflow_context, internal_id=a_ret.internal_id)
0046     test_result = "AsyncResult test (request_id: %s)" % (workflow_context.request_id)
0047     logging.info("AsyncResult publish: %s" % test_result)
0048     async_ret.publish(test_result)
0049 
0050     ret_q = a_ret.wait_result()
0051     logging.info("AsyncResult results: %s" % str(ret_q))