Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
network
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
9
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
network
Commits
0c9f3d1d
Verified
Commit
0c9f3d1d
authored
2 years ago
by
Georg Krause
Browse files
Options
Downloads
Patches
Plain Diff
Use a common pool for a running task
parent
a58bf555
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#26557
failed with stages
in 5 minutes and 22 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
funkwhale_network/cli.py
+6
-11
6 additions, 11 deletions
funkwhale_network/cli.py
funkwhale_network/db.py
+16
-6
16 additions, 6 deletions
funkwhale_network/db.py
with
22 additions
and
17 deletions
funkwhale_network/cli.py
+
6
−
11
View file @
0c9f3d1d
...
...
@@ -162,6 +162,8 @@ async def poll(domains):
"""
from
.
import
crawler
await
DB
.
create_pool
()
if
not
domains
:
async
with
DB
()
as
db
:
domains_db
=
await
db
.
get_all_domains
()
...
...
@@ -170,7 +172,10 @@ async def poll(domains):
kwargs
=
crawler
.
get_session_kwargs
()
async
with
aiohttp
.
ClientSession
(
**
kwargs
)
as
session
:
tasks
=
[
launch_domain_poll
(
session
,
d
)
for
d
in
domains
]
return
await
asyncio
.
wait
(
tasks
)
await
asyncio
.
wait
(
tasks
)
await
DB
.
close_pool
()
return
NOOP
=
object
()
...
...
@@ -298,16 +303,6 @@ def aggregate_crawl_results(domains_info):
@click.option
(
"
--check
"
,
is_flag
=
True
)
def
start
(
*
,
check
,
verbose
):
arq
.
worker
.
run_worker
(
WorkerSettings
)
# TODO launch runner
# worker = arq.worker.import_string("funkwhale_network.worker", "Worker")
# logging.config.dictConfig(worker.logging_config(verbose))
if
check
:
pass
# exit(worker.check_health())
else
:
pass
# arq.RunWorkerProcess("funkwhale_network.worker", "Worker", burst=False)
def
main
():
...
...
This diff is collapsed.
Click to expand it.
funkwhale_network/db.py
+
16
−
6
View file @
0c9f3d1d
...
...
@@ -5,6 +5,8 @@ from funkwhale_network import settings
class
DB
:
pool
:
aiopg
.
Pool
def
__init__
(
self
):
self
.
TABLES
=
[
(
"
domains
"
,
self
.
create_domains_table
),
...
...
@@ -12,15 +14,23 @@ class DB:
]
async
def
__aenter__
(
self
):
await
self
.
create_pool
()
await
DB
.
create_pool
()
return
self
async
def
__aexit__
(
self
,
*
excinfo
):
self
.
pool
.
close
()
await
self
.
pool
.
wait_closed
()
async
def
__aexit__
(
self
,
exc_type
,
exc
,
tb
):
return
@classmethod
async
def
close_pool
(
cls
):
cls
.
pool
.
close
()
await
cls
.
pool
.
wait_closed
()
async
def
create_pool
(
self
):
self
.
pool
=
await
aiopg
.
create_pool
(
settings
.
DB_DSN
)
@classmethod
async
def
create_pool
(
cls
):
try
:
cls
.
pool
except
AttributeError
:
cls
.
pool
=
await
aiopg
.
create_pool
(
settings
.
DB_DSN
)
def
get_cursor
(
self
):
yield
self
.
pool
.
cursor
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment