Skip to content

Commit

Permalink
Ability to pass request headers in task
Browse files Browse the repository at this point in the history
  • Loading branch information
volbil committed May 19, 2024
1 parent 97c4e11 commit e167566
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kibun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ async def kibun_loop(tasks, semaphore_number=1):
semaphore = asyncio.Semaphore(semaphore_number)
step = 0

logger.info(f"Got {len(tasks)} tasks")
if len(tasks) > 0:
logger.info(f"Got {len(tasks)} tasks")

while len(tasks) > 0:
# Shuffle tasks to make them less predictable
Expand Down
1 change: 1 addition & 0 deletions kibun/backend/aio/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ async def request_aio(session, endpoint, task):
params=task.params,
method=task.method,
proxy=task.proxy,
headers=task.headers,
error_markers=task.error_markers,
)

Expand Down
3 changes: 3 additions & 0 deletions kibun/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Task:
delete_kwargs: dict
max_fails: int | None
error_markers: list
headers: dict | None


@dataclass
Expand Down Expand Up @@ -67,6 +68,7 @@ def create_task(
delete_kwargs={},
max_fails=10,
error_markers=constants.DEFAULT_MARKERS,
headers=None,
):
if constants.NETWORK_ERROR not in done_status:
done_status.append(constants.NETWORK_ERROR)
Expand Down Expand Up @@ -101,6 +103,7 @@ def create_task(
delete_kwargs,
max_fails,
error_markers,
headers,
)


Expand Down

0 comments on commit e167566

Please sign in to comment.