Skip to content

Commit 8167742

Browse files
authored
Merge pull request #741 from stvoutsin/run_async-docs
DOCS: Add run_async example to the docs
2 parents 336d9e1 + 5c5dfa2 commit 8167742

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

docs/dal/index.rst

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,27 +250,32 @@ robust of long-running queries. It also supports queuing queries,
250250
which allows service operators to be a lot more generous with
251251
resource limits.
252252

253-
To specify the query mode, you can use either ``run_sync()`` for
254-
synchronous query or ``run_async()`` for asynchronous query.
253+
For most long-running queries, ``run_async()`` should generally be the
254+
preferred approach. It submits the job, waits for it to complete, and returns
255+
the result in one call:
256+
257+
.. doctest-remote-data::
258+
259+
>>> result = tap_service.run_async(ex_query)
260+
261+
For more control over the job lifecycle, for example to set a
262+
custom execution time limit, inspect the job URL, or manage the job
263+
manually you can use the ``submit_job()`` workflow instead. This submits an
264+
asynchronous query without starting it, returning an
265+
:py:class:`~pyvo.dal.AsyncTAPJob` object:
255266

256267
.. doctest-remote-data::
257268

258269
>>> job = tap_service.submit_job(ex_query)
259270

260-
To learn more details from the asynchronous query, let's look at the
261-
``submit_job()`` method. This submits an asynchronous query without
262-
starting it, it creates a new object :py:class:`~pyvo.dal.AsyncTAPJob`.
271+
The job URL is in the ``url`` attribute and can be used to inspect or
272+
manage the job. The same is available programmatically via various attributes:
263273

264274
.. doctest-remote-data::
265275

266276
>>> job.url
267277
'http://dc.g-vo.org/__system__/tap/run/async/...'
268278

269-
The job URL mentioned before is available in the ``url`` attribute.
270-
Clicking on the URL leads you to the query itself, where you can check
271-
the status(phase) of the query and decide to run, modify or delete
272-
the job. You can also do it via various attributes:
273-
274279
.. doctest-remote-data::
275280

276281
>>> job.phase
@@ -332,10 +337,6 @@ that you can change if you need to) is reached.
332337
For more attributes please read the description for the job object
333338
:py:class:`~pyvo.dal.AsyncTAPJob`.
334339

335-
With ``run_async()`` you basically submit an asynchronous query and
336-
return its result. It is like running ``submit_job()`` first and then
337-
run the query manually.
338-
339340
Query limit
340341
^^^^^^^^^^^
341342

0 commit comments

Comments
 (0)