Skip to content

Commit e35136e

Browse files
committed
reduce passing processor in static methods
1 parent a93ea43 commit e35136e

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

server/recceiver/cfstore.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def handle_channel_is_old(
658658
iocs: Dict[str, IocInfo],
659659
ioc_info: IocInfo,
660660
recceiverid: str,
661-
processor: CFProcessor,
661+
managed_properties: Set[str],
662662
cf_config: CFConfig,
663663
channels: List[CFChannel],
664664
record_info_by_name: Dict[str, RecordInfo],
@@ -674,7 +674,7 @@ def handle_channel_is_old(
674674
iocs: List of all known iocs
675675
ioc_info: Current ioc
676676
recceiverid: id of current recceiver
677-
processor: Processor going through transaction
677+
managed_properties: List of managed properties
678678
cf_config: Configuration used for processor
679679
channels: list of the current channel changes
680680
record_info_by_name: Input information from the transaction
@@ -684,7 +684,7 @@ def handle_channel_is_old(
684684
cf_channel.properties = __merge_property_lists(
685685
create_default_properties(ioc_info, recceiverid, channel_ioc_ids, iocs, cf_channel),
686686
cf_channel,
687-
processor.managed_properties,
687+
managed_properties,
688688
)
689689
channels.append(cf_channel)
690690
_log.debug("Add existing channel %s to previous IOC %s", cf_channel, last_ioc_id)
@@ -706,7 +706,7 @@ def handle_channel_is_old(
706706
cf_channel,
707707
),
708708
alias_channel,
709-
processor.managed_properties,
709+
managed_properties,
710710
)
711711
channels.append(alias_channel)
712712
_log.debug("Add existing alias %s to previous IOC: %s", alias_channel, last_alias_ioc_id)
@@ -760,7 +760,7 @@ def handle_channel_old_and_new(
760760
cf_channel: CFChannel,
761761
iocid: str,
762762
ioc_info: IocInfo,
763-
processor: CFProcessor,
763+
managed_properties: Set[str],
764764
channels: List[CFChannel],
765765
new_channels: Set[str],
766766
cf_config: CFConfig,
@@ -779,7 +779,7 @@ def handle_channel_old_and_new(
779779
cf_channel: The channel to update
780780
iocid: The IOC ID of the channel
781781
ioc_info: Info of the current ioc
782-
processor: Processor going through transaction
782+
managed_properties: List of managed properties
783783
channels: The current list of channel changes
784784
new_channels: The list of new channels
785785
cf_config: Configuration of the processor
@@ -793,7 +793,7 @@ def handle_channel_old_and_new(
793793
CFProperty.time(ioc_info.owner, ioc_info.time),
794794
],
795795
cf_channel,
796-
processor.managed_properties,
796+
managed_properties,
797797
)
798798
channels.append(cf_channel)
799799
_log.debug("Add existing channel with same IOC: %s", cf_channel)
@@ -812,7 +812,7 @@ def handle_channel_old_and_new(
812812
CFProperty.time(ioc_info.owner, ioc_info.time),
813813
],
814814
alias_channel,
815-
processor.managed_properties,
815+
managed_properties,
816816
)
817817
channels.append(alias_channel)
818818
new_channels.remove(alias_name)
@@ -828,7 +828,7 @@ def handle_channel_old_and_new(
828828
),
829829
],
830830
cf_channel,
831-
processor.managed_properties,
831+
managed_properties,
832832
)
833833
channels.append(
834834
CFChannel(
@@ -842,15 +842,14 @@ def handle_channel_old_and_new(
842842

843843

844844
def get_existing_channels(
845-
new_channels: Set[str], client: ChannelFinderClient, cf_config: CFConfig, processor: CFProcessor
845+
new_channels: Set[str], client: ChannelFinderClient, cf_config: CFConfig
846846
) -> Dict[str, CFChannel]:
847847
"""Get the channels existing in channelfinder from the list of new channels.
848848
849849
Args:
850850
new_channels: The list of new channels.
851851
client: The client to contact channelfinder
852852
cf_config: The configuration for the processor.
853-
processor: The processor.
854853
"""
855854
existing_channels: Dict[str, CFChannel] = {}
856855

@@ -874,10 +873,6 @@ def get_existing_channels(
874873
prepareFindArgs(cf_config=cf_config, args=[("~name", each_search_string)])
875874
):
876875
existing_channels[found_channel["name"]] = CFChannel.from_channelfinder_dict(found_channel)
877-
if processor.cancelled:
878-
raise defer.CancelledError(
879-
f"CF Processor is cancelled, while searching for existing channels: {each_search_string}"
880-
)
881876
return existing_channels
882877

883878

@@ -889,7 +884,7 @@ def handle_channels(
889884
iocs: Dict[str, IocInfo],
890885
ioc_info: IocInfo,
891886
recceiverid: str,
892-
processor: CFProcessor,
887+
managed_properties: Set[str],
893888
cf_config: CFConfig,
894889
channels: List[CFChannel],
895890
record_info_by_name: Dict[str, RecordInfo],
@@ -923,7 +918,6 @@ def handle_channels(
923918
record_info_by_name: The dictionary of record names to information.
924919
iocid: The IOC ID.
925920
cf_config: The configuration for the processor.
926-
processor: The processor.
927921
"""
928922
for cf_channel in old_channels:
929923
if (
@@ -937,7 +931,7 @@ def handle_channels(
937931
iocs,
938932
ioc_info,
939933
recceiverid,
940-
processor,
934+
managed_properties,
941935
cf_config,
942936
channels,
943937
record_info_by_name,
@@ -950,7 +944,7 @@ def handle_channels(
950944
cf_channel,
951945
iocid,
952946
ioc_info,
953-
processor,
947+
managed_properties,
954948
channels,
955949
new_channels,
956950
cf_config,
@@ -963,7 +957,7 @@ def update_existing_channel_diff_iocid(
963957
existing_channels: Dict[str, CFChannel],
964958
channel_name: str,
965959
new_properties: List[CFProperty],
966-
processor: CFProcessor,
960+
managed_properties: Set[str],
967961
channels: List[CFChannel],
968962
cf_config: CFConfig,
969963
record_info_by_name: Dict[str, RecordInfo],
@@ -979,7 +973,7 @@ def update_existing_channel_diff_iocid(
979973
existing_channels: The dictionary of existing channels.
980974
channel_name: The name of the channel.
981975
new_properties: The new properties.
982-
processor: The processor.
976+
managed_properties: The managed properties.
983977
channels: The list of channels.
984978
cf_config: configuration of processor
985979
record_info_by_name: The dictionary of record names to information.
@@ -990,7 +984,7 @@ def update_existing_channel_diff_iocid(
990984
existing_channel.properties = __merge_property_lists(
991985
new_properties,
992986
existing_channel,
993-
processor.managed_properties,
987+
managed_properties,
994988
)
995989
channels.append(existing_channel)
996990
_log.debug("Add existing channel with different IOC: %s", existing_channel)
@@ -1006,7 +1000,7 @@ def update_existing_channel_diff_iocid(
10061000
ach.properties = __merge_property_lists(
10071001
alias_properties,
10081002
ach,
1009-
processor.managed_properties,
1003+
managed_properties,
10101004
)
10111005
channels.append(ach)
10121006
else:
@@ -1098,14 +1092,17 @@ def _update_channelfinder(
10981092
iocs,
10991093
ioc_info,
11001094
recceiverid,
1101-
processor,
1095+
processor.managed_properties,
11021096
cf_config,
11031097
channels,
11041098
record_info_by_name,
11051099
iocid,
11061100
)
11071101
# now pvNames contains a list of pv's new on this host/ioc
1108-
existing_channels = get_existing_channels(new_channels, client, cf_config, processor)
1102+
existing_channels = get_existing_channels(new_channels, client, cf_config)
1103+
1104+
if processor.cancelled:
1105+
raise defer.CancelledError(f"CF Processor is cancelled, after fetching existing channels for {ioc_info}")
11091106

11101107
for channel_name in new_channels:
11111108
new_properties = create_ioc_properties(
@@ -1132,7 +1129,7 @@ def _update_channelfinder(
11321129
existing_channels,
11331130
channel_name,
11341131
new_properties,
1135-
processor,
1132+
processor.managed_properties,
11361133
channels,
11371134
cf_config,
11381135
record_info_by_name,

0 commit comments

Comments
 (0)