@@ -131,6 +131,16 @@ def _refresh_task_accessors(obj):
131
131
_refresh_task_accessors (task )
132
132
133
133
134
+ def _call_refresh_task_accessors (obj ):
135
+ """This layer handles exception for PyConsole."""
136
+ try :
137
+ _refresh_task_accessors (obj )
138
+ except Exception :
139
+ # Is there a more specific Exception derived class
140
+ # for which we know it is correct to pass?
141
+ pass
142
+
143
+
134
144
def _convert_task_list_to_display_names (workflow_root , task_list ):
135
145
if workflow_root .service .cache is not None :
136
146
workflow_state = workflow_root .service .cache .get_state (
@@ -1280,37 +1290,41 @@ def __init__(
1280
1290
command_source : PyMenuGeneric
1281
1291
The application root for commanding.
1282
1292
"""
1283
- self ._workflow = workflow
1284
- self ._command_source = command_source
1285
- self ._python_task_names = []
1286
- self ._lock = threading .RLock ()
1287
- self ._refreshing = False
1288
- self ._dynamic_python_names = False
1289
- self ._refresh_count = 0
1290
- self ._ordered_children = []
1291
- self ._task_list = []
1292
- self ._getattr_recurse_depth = 0
1293
- self ._main_thread_ident = None
1294
- self ._task_objects = {}
1295
- self ._dynamic_interface = False
1296
- self ._python_name_command_id_map = {}
1297
- self ._python_name_display_id_map = {}
1298
- self ._python_name_display_text_map = {}
1299
- self ._repeated_task_python_name_display_text_map = {}
1300
- self ._initial_task_python_names_map = {}
1301
- self ._unwanted_attrs = {
1302
- "reset_workflow" ,
1303
- "initialize_workflow" ,
1304
- "load_workflow" ,
1305
- "insert_new_task" ,
1306
- "create_composite_task" ,
1307
- "create_new_workflow" ,
1308
- "rules" ,
1309
- "service" ,
1310
- "task_object" ,
1311
- "workflow" ,
1312
- }
1313
- self ._fluent_version = fluent_version
1293
+ self .__dict__ .update (
1294
+ dict (
1295
+ _workflow = workflow ,
1296
+ _command_source = command_source ,
1297
+ _python_task_names = [],
1298
+ _lock = threading .RLock (),
1299
+ _refreshing = False ,
1300
+ _dynamic_python_names = False ,
1301
+ _refresh_count = 0 ,
1302
+ _ordered_children = [],
1303
+ _task_list = [],
1304
+ _getattr_recurse_depth = 0 ,
1305
+ _main_thread_ident = None ,
1306
+ _task_objects = {},
1307
+ _dynamic_interface = False ,
1308
+ _python_name_command_id_map = {},
1309
+ _python_name_display_id_map = {},
1310
+ _python_name_display_text_map = {},
1311
+ _repeated_task_python_name_display_text_map = {},
1312
+ _initial_task_python_names_map = {},
1313
+ _unwanted_attrs = {
1314
+ "reset_workflow" ,
1315
+ "initialize_workflow" ,
1316
+ "load_workflow" ,
1317
+ "insert_new_task" ,
1318
+ "create_composite_task" ,
1319
+ "create_new_workflow" ,
1320
+ "rules" ,
1321
+ "service" ,
1322
+ "task_object" ,
1323
+ "workflow" ,
1324
+ },
1325
+ _fluent_version = fluent_version ,
1326
+ )
1327
+ )
1314
1328
1315
1329
def task (self , name : str ) -> BaseTask :
1316
1330
"""Get a TaskObject by name, in a ``BaseTask`` wrapper.
@@ -1414,6 +1428,14 @@ def __getattr__(self, attr):
1414
1428
return obj
1415
1429
return super ().__getattribute__ (attr )
1416
1430
1431
+ def __setattr__ (self , attr , value ):
1432
+ if attr in self .__dict__ :
1433
+ self .__dict__ [attr ] = value
1434
+ elif attr in self ._task_objects :
1435
+ self ._task_objects [attr ].set_state (value )
1436
+ else :
1437
+ super ().__setattr__ (attr , value )
1438
+
1417
1439
def __dir__ (self ):
1418
1440
"""Override the behavior of ``dir`` to include attributes in the
1419
1441
``WorkflowWrapper`` class and the underlying workflow."""
@@ -1467,7 +1489,6 @@ def _activate_dynamic_interface(self, dynamic_interface: bool):
1467
1489
self ._initialize_methods (dynamic_interface = dynamic_interface )
1468
1490
1469
1491
def _unsubscribe_root_affected_callback (self ):
1470
- # if the same workflow is not being reinitialized, unsubscribe the root affected callback
1471
1492
if self ._workflow .service in self ._root_affected_cb_by_server :
1472
1493
self ._root_affected_cb_by_server [self ._workflow .service ].unsubscribe ()
1473
1494
self ._root_affected_cb_by_server .pop (self ._workflow .service )
@@ -1557,12 +1578,7 @@ def refresh_after_sleep(_):
1557
1578
logger .debug ("Already _refreshing, ..." )
1558
1579
self ._refreshing = True
1559
1580
logger .debug ("Call _refresh_task_accessors" )
1560
- try :
1561
- _refresh_task_accessors (self )
1562
- except Exception :
1563
- # Is there a more specific Exception derived class
1564
- # for which we know it is correct to pass?
1565
- pass
1581
+ _call_refresh_task_accessors (self )
1566
1582
self ._refresh_count += 1
1567
1583
self ._refreshing = False
1568
1584
0 commit comments