mik-laj commented on a change in pull request #4891: Telegram hook/operator to
post messages to telegram channels
URL: https://github.com/apache/airflow/pull/4891#discussion_r264048716
##########
File path: airflow/contrib/hooks/telegram_hook.py
##########
@@ -0,0 +1,88 @@
+import telegram
+from time import sleep
+from airflow.hooks.base_hook import BaseHook
+from airflow.exceptions import AirflowException
+
+
+def telegram_retry(func, *args, **kwargs):
+ max_retries = kwargs.pop("max_retries", 5)
+ retry_sleep = kwargs.pop("retry_sleep", 0)
+ # perform request with retry
+ for retry in range(max_retries):
+ try:
+ return func(*args, **kwargs)
+ except (telegram.error.TimedOut,) as e:
Review comment:
Why only this error? What if an internal server error happens? Then you also
need to retry.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services