Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
Signed-off-by: technillogue <technillogue@gmail.com>
  • Loading branch information
technillogue committed Feb 19, 2024
1 parent a6f43a4 commit 3563178
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions python/cog/server/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ async def upload_file(self, fh: io.IOBase, url: Optional[str]) -> str:
fh.seek(0)
# try to guess the filename of the given object
name = getattr(fh, "name", "file")
filename = os.path.basename(name)
filename = os.path.basename(name) or "file"
assert isinstance(filename, str)

guess, _ = mimetypes.guess_type(filename)
content_type = guess or "application/octet-stream"
Expand Down Expand Up @@ -179,7 +180,7 @@ async def chunk_file_reader() -> AsyncIterator[bytes]:
headers={"Content-Type": content_type},
follow_redirects=False,
)
if resp1.status_code == 307:
if resp1.status_code == 307 and resp1.headers["Location"]:
url = resp1.headers["Location"]
resp = await self.file_client.put(
url,
Expand Down
8 changes: 5 additions & 3 deletions python/cog/server/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ def cancel(self, prediction_id: str) -> None:
if id not in self._predictions_in_flight:
log.warn("can't cancel %s (%s)", prediction_id, self._predictions_in_flight)
raise UnknownPredictionError()
if self._child.is_alive() and self._child.pid is not None:
os.kill(self._child.pid, signal.SIGUSR1)
maybe_pid = self._child.pid
if self._child.is_alive() and maybe_pid is not None:
os.kill(maybe_pid, signal.SIGUSR1)
log.info("sent cancel")
self._events.send(Cancel(prediction_id))
# maybe this should probably check self._semaphore._value == self._concurrent
Expand Down Expand Up @@ -396,7 +397,8 @@ def __init__(

self._client_manager = client_manager
self._webhook_sender = client_manager.make_webhook_sender(
request.webhook, request.webhook_events_filter
request.webhook,
request.webhook_events_filter or schema.WebhookEvent.default_events(),
)
self._upload_url = upload_url
self._output_type = None
Expand Down

0 comments on commit 3563178

Please sign in to comment.