File indexing completed on 2026-04-09 07:58:21
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 import inspect
0013 import logging
0014 import os
0015 import shutil
0016 import sys
0017
0018
0019 from idds.common.utils import setup_logging
0020
0021 from idds.iworkflow.asyncresult import AsyncResult
0022 from idds.iworkflow.workflow import Workflow
0023
0024 setup_logging(__name__)
0025
0026
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))