Skip to content

Commit

Permalink
Switched to temporary pq (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmingles committed Oct 17, 2024
1 parent bbdabf8 commit 47cd6c8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const CONFIG_KEY = {

export const DEFAULT_CONSOLE_TYPE = 'python' as const;
// export const DHFS_SCHEME = 'dhfs';
export const DEFAULT_TEMPORARY_QUERY_TIMEOUT_MS = 60000 as const;

export const PYTHON_ENV_WAIT = 1500 as const;

Expand Down
24 changes: 14 additions & 10 deletions src/dh/dhe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
WorkerInfo,
WorkerURL,
} from '../types';
import { DEFAULT_TEMPORARY_QUERY_TIMEOUT_MS } from '../common';

const INTERACTIVE_CONSOLE_QUERY_TYPE = 'InteractiveConsole';

Expand Down Expand Up @@ -131,14 +132,10 @@ export async function createInteractiveConsoleQuery(
) ?? 'Python';
const workerKind = serverConfigValues.workerKinds?.[0]?.name;

const timeZone =
serverConfigValues.timeZone ??
Intl.DateTimeFormat().resolvedOptions().timeZone;

const scheduling = QueryScheduler.makeDefaultScheduling(
serverConfigValues.restartQueryWhenRunningDefault,
timeZone
);
const scheduling = QueryScheduler.makeTemporaryScheduling({
autoDelete: true,
queueName: 'InteractiveConsoleTemporaryQueue',
});

const draftQuery = new DraftQuery({
isClientSide: true,
Expand All @@ -149,10 +146,12 @@ export async function createInteractiveConsoleQuery(
dbServerName,
heapSize: heapSize,
scheduling,
// TODO: deephaven/vscode-deephaven/issues/153 to update this to secure websocket connection
// We have to use websockets since http2 is not sufficiently supported in
// the nodejs environment (v20 at time of this comment).
jvmArgs: '-Dhttp.websockets=true',
jvmProfile,
scriptLanguage,
timeout: DEFAULT_TEMPORARY_QUERY_TIMEOUT_MS,
workerKind,
});

Expand All @@ -162,7 +161,12 @@ export async function createInteractiveConsoleQuery(

// type assertion gives us stronger type safety than the Promise<string>
// return type defined by the JS API types.
return dheClient.createQuery(draftQuery) as Promise<QuerySerial>;
const serial = (await dheClient.createQuery(draftQuery)) as QuerySerial;

// Temporary queries don't auto start, so we need to start it manually.
dheClient.restartQueries([serial]);

return serial;
}

/**
Expand Down

0 comments on commit 47cd6c8

Please sign in to comment.