aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/book_bbg.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/python/book_bbg.py b/python/book_bbg.py
index a0c6d9a8..fae9dd97 100644
--- a/python/book_bbg.py
+++ b/python/book_bbg.py
@@ -8,15 +8,18 @@ import time
def run():
sftp = SftpClient.from_creds("bbg")
while True:
- for f in sftp.client.listdir_iter("/"):
- if S_ISREG(f.st_mode):
- if m := re.match("(CDX|BOND)-[^_]*_([^$]*)", f.filename):
- deal_type, bbg_id = m.groups()
- if bbg_id not in BbgDeal._cache:
- with sftp.client.open(f.filename) as fh:
- Deal[DealType(deal_type)].process(fh, bbg_id)
- BbgDeal._cache[bbg_id] = None
-
+ try:
+ for f in sftp.client.listdir_iter("/"):
+ if S_ISREG(f.st_mode):
+ if m := re.match("(CDX|BOND)-[^_]*_([^$]*)", f.filename):
+ deal_type, bbg_id = m.groups()
+ if bbg_id not in BbgDeal._cache:
+ with sftp.client.open(f.filename) as fh:
+ Deal[DealType(deal_type)].process(fh, bbg_id)
+ BbgDeal._cache[bbg_id] = None
+ except OSError:
+ sftp.client.close()
+ sftp = SftpClient.from_creds("bbg")
time.sleep(60)