pybgpkitstream 0.1.1__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pybgpkitstream
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Drop-in replacement for PyBGPStream using BGPKIT
5
5
  Author: JustinLoye
6
6
  Author-email: JustinLoye <jloye@iij.ad.jp>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pybgpkitstream"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "Drop-in replacement for PyBGPStream using BGPKIT"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -53,6 +53,7 @@ class BGPKITStream:
53
53
  data_type: list[Literal["update", "rib"]],
54
54
  cache_dir: str | None,
55
55
  filters: dict = {},
56
+ max_concurrent_downloads: int = 10,
56
57
  ):
57
58
  self.ts_start = ts_start
58
59
  self.ts_end = ts_end
@@ -60,6 +61,7 @@ class BGPKITStream:
60
61
  self.data_type = data_type
61
62
  self.cache_dir = cache_dir
62
63
  self.filters = filters
64
+ self.max_concurrent_downloads = max_concurrent_downloads
63
65
 
64
66
  self.broker = bgpkit.Broker()
65
67
 
@@ -129,8 +131,7 @@ class BGPKITStream:
129
131
  self.paths = {"rib": defaultdict(list), "update": defaultdict(list)}
130
132
  tasks = []
131
133
 
132
- CONCURRENT_DOWNLOADS = 10
133
- semaphore = asyncio.Semaphore(CONCURRENT_DOWNLOADS)
134
+ semaphore = asyncio.Semaphore(self.max_concurrent_downloads)
134
135
 
135
136
  conn = aiohttp.TCPConnector()
136
137
  async with aiohttp.ClientSession(connector=conn) as session:
@@ -154,7 +155,7 @@ class BGPKITStream:
154
155
 
155
156
  if tasks:
156
157
  logging.info(
157
- f"Starting download of {len(tasks)} files with a concurrency of {CONCURRENT_DOWNLOADS}..."
158
+ f"Starting download of {len(tasks)} files with a concurrency of {self.max_concurrent_downloads}..."
158
159
  )
159
160
  results = await asyncio.gather(*tasks)
160
161
 
@@ -225,4 +226,7 @@ class BGPKITStream:
225
226
  filters=config.filters.model_dump(exclude_unset=True)
226
227
  if config.filters
227
228
  else {},
229
+ max_concurrent_downloads=config.max_concurrent_downloads
230
+ if config.max_concurrent_downloads
231
+ else 10,
228
232
  )
@@ -63,3 +63,4 @@ class BGPStreamConfig(BaseModel):
63
63
  description="Specifies the directory for caching downloaded files.",
64
64
  )
65
65
  filters: FilterOptions | None = Field(default=None, description="Optional filters")
66
+ max_concurrent_downloads: int | None = Field(default=None, description="Maximum concurrent downloads when caching")
File without changes