pup-py commited on
Commit
2c8258c
·
1 Parent(s): 04d1a17

self ping correct host

Browse files
Files changed (2) hide show
  1. fetch.py +6 -4
  2. pyproject.toml +1 -1
fetch.py CHANGED
@@ -4,6 +4,7 @@ from contextlib import asynccontextmanager
4
  from datetime import datetime
5
  from fastapi import FastAPI, Request
6
  from fastapi.responses import FileResponse, PlainTextResponse, Response
 
7
  from pathlib import Path
8
  from typing import Any
9
 
@@ -129,13 +130,14 @@ async def ping():
129
  return {"message": "woof!"}
130
 
131
 
132
- async def self_ping():
133
- async with httpx.AsyncClient() as client:
134
- _ = await client.get("http://0.0.0.0:7860/ping")
 
135
 
136
 
137
  scheduler = AsyncIOScheduler(executors={"default": AsyncIOExecutor()})
138
- scheduler.add_job(self_ping, "interval", minutes=60)
139
 
140
 
141
  if __name__ == "__main__":
 
4
  from datetime import datetime
5
  from fastapi import FastAPI, Request
6
  from fastapi.responses import FileResponse, PlainTextResponse, Response
7
+ from os import getenv
8
  from pathlib import Path
9
  from typing import Any
10
 
 
130
  return {"message": "woof!"}
131
 
132
 
133
+ def self_ping():
134
+ self_host = getenv("SPACE_HOST", "http://0.0.0.0:7860")
135
+ with httpx.Client() as client:
136
+ _ = client.get(f"{self_host}/ping")
137
 
138
 
139
  scheduler = AsyncIOScheduler(executors={"default": AsyncIOExecutor()})
140
+ scheduler.add_job(self_ping, "interval", minutes=1)
141
 
142
 
143
  if __name__ == "__main__":
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
  [project]
2
  name = "fetch"
3
- version = "0.3.3"
4
  description = "Puppy Installer"
5
  authors = [
6
  { name = "Alex Kislukhin" }
 
1
  [project]
2
  name = "fetch"
3
+ version = "0.3.4"
4
  description = "Puppy Installer"
5
  authors = [
6
  { name = "Alex Kislukhin" }