I have to to call my update chat task in sync/async way based on a flag variable. I have a code something like this:
class UpdateChat:
def __init__(self, is_async=True):
self._async = is_async
def update(self):
parse_call = self._parse_async if self._async else self._parse_sync
parse_call(utterance,dynamic_concepts,cache_id_str)
# This should have ideally mapped correctly with function parameters of _parse_sync & _parse_async
# But somehow:
# - utterance is being mapped with dynamic_concepts
# - dynamic_concepts with cache_id_str
# cache_id_str not being mapped at all
def _parse_sync(self, utterance, dynamic_concepts=None, cache_id_str=None):
pass
def _parse_async(self, utterance, dynamic_concepts=None, cache_id_str=None):
pass
The update function is not mapping the parameters being passed in parse_call correctly( as mentioned in the comments above)
Two Questions, If i may:
- Why is this happening?
- Is this correct way of implementing such features ( from a design pattern perspective? ) Should we use Interface ( Python ABC ) or something else insead of mappings like this?
Aucun commentaire:
Enregistrer un commentaire