Upgrading Sanic and yt-dlp. Major changes occurred because Sanic changed how multiprocessing works.

Python 3.11 is now required, old versions were causing unpredictability in tests.  (Sanic does not yet
support 3.12)

Sanic has been upgraded to 23.6.0, which is the latest version that avoids this bug:
 https://github.com/sanic-org/sanic/issues/2921

New strategy for multiprocessing is to create all multiprocessing tools in one process, then fork
to other processes.  The previous strategy was to declare multiprocessing tools at the top of every
file, or wherever they were needed at import/creation.  Now all multiprocessing tools are attached to the
app.shared_ctx.  This means `api_app` is imported in many, many places.

This forced a change in how the DownloadManager works.  Previously, it would continually run
download workers which would pull downloads from a multiprocessing.Queue.  Now, a single worker checks
for new downloads and sends a Sanic signal.

Flags have been reworked to use the `api_app`.  I removed the `which` flag functionality because the
`which` are called at import and needed their own multiprocessing.Event.
This commit is contained in:
Roland 2024-04-17 11:25:26 -06:00
parent 2c127a03f5
commit 58de8c7c5b
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
65 changed files with 1238 additions and 1058 deletions

View file

@ -1,5 +1,12 @@
import React from "react";
import {clearCompletedDownloads, clearFailedDownloads, deleteDownload, killDownload, restartDownload} from "../../api";
import {
clearCompletedDownloads,
clearFailedDownloads,
deleteDownload,
deleteOnceDownloads,
killDownload,
restartDownload
} from "../../api";
import {Link} from "react-router-dom";
import {
APIButton,
@ -40,7 +47,7 @@ function ClearCompleteDownloads({callback}) {
return <>
<APIButton
onClick={localClearDownloads}
color='yellow'
color='violet'
obeyWROLMode={true}
>Clear Completed</APIButton>
</>
@ -58,7 +65,7 @@ function ClearFailedDownloads({callback}) {
}
return <APIButton
color='red'
color='yellow'
onClick={localDeleteFailed}
confirmContent='Are you sure you want to delete failed downloads? They will not be retried.'
confirmButton='Delete'
@ -68,6 +75,28 @@ function ClearFailedDownloads({callback}) {
</APIButton>
}
function DeleteOnceDownloads({callback}) {
async function localDeleteOnce() {
try {
await deleteOnceDownloads();
} finally {
if (callback) {
callback()
}
}
}
return <APIButton
color='red'
onClick={localDeleteOnce}
confirmContent='Are you sure you want to delete all downloads? They may be retried!'
confirmButton='Delete'
obeyWROLMode={true}
>
Delete All
</APIButton>
}
class RecurringDownloadRow extends React.Component {
constructor(props) {
super(props);
@ -306,6 +335,7 @@ export function OnceDownloadsTable({downloads, fetchDownloads}) {
<TableHeaderCell colSpan={3}>
<ClearCompleteDownloads callback={fetchDownloads}/>
<ClearFailedDownloads callback={fetchDownloads}/>
<DeleteOnceDownloads callback={fetchDownloads}/>
</TableHeaderCell>
</TableRow>
</TableFooter>