Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions exts/rag_bge_small_en_v15/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub extern "C-unwind" fn background_main(arg: pg_sys::Datum) {
.build()
.expect_or_pg_err("Couldn't build tokio runtime for server")
.block_on(async {
unsafe { pg_sys::BackgroundWorkerBlockSignals() };
let path = socket_path!(pid);
fs::remove_file(&path).unwrap_or_default(); // it's not an error if the file isn't there
let uds = UnixListener::bind(&path).expect_or_pg_err(&format!("Couldn't create socket at {}", &path));
Expand All @@ -166,10 +167,13 @@ pub extern "C-unwind" fn background_main(arg: pg_sys::Datum) {
Server::builder()
.add_service(EmbeddingGeneratorServer::new(embedder))
.serve_with_incoming_shutdown(uds_stream, async {
unsafe { pg_sys::BackgroundWorkerUnblockSignals() };
// wait_latch is not an async function and does not suspend
while BackgroundWorker::wait_latch(Some(Duration::from_secs(0))) {
unsafe { pg_sys::BackgroundWorkerBlockSignals() };
// suspend so that other asyncs/threads can run
sleep(Duration::from_millis(500)).await;
unsafe { pg_sys::BackgroundWorkerUnblockSignals() };
}
})
.await
Expand Down
4 changes: 4 additions & 0 deletions exts/rag_jina_reranker_v1_tiny_en/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub extern "C-unwind" fn background_main(arg: pg_sys::Datum) {
.build()
.expect_or_pg_err("Couldn't build tokio runtime for server")
.block_on(async {
unsafe { pg_sys::BackgroundWorkerBlockSignals() };
let path = socket_path!(pid);
fs::remove_file(&path).unwrap_or_default(); // it's not an error if the file isn't there
let uds = UnixListener::bind(&path).expect_or_pg_err(&format!("Couldn't create socket at {}", &path));
Expand All @@ -170,10 +171,13 @@ pub extern "C-unwind" fn background_main(arg: pg_sys::Datum) {
Server::builder()
.add_service(RerankerServer::new(reranker))
.serve_with_incoming_shutdown(uds_stream, async {
unsafe { pg_sys::BackgroundWorkerUnblockSignals() };
// wait_latch is not an async function and does not suspend
while BackgroundWorker::wait_latch(Some(Duration::from_secs(0))) {
unsafe { pg_sys::BackgroundWorkerBlockSignals() };
// suspend so that other asyncs/threads can run
sleep(Duration::from_millis(500)).await;
unsafe { pg_sys::BackgroundWorkerUnblockSignals() };
}
})
.await
Expand Down