compass.services.threaded.JurisdictionUpdater#

class JurisdictionUpdater(jurisdiction_fp, tpe_kwargs=None)[source]#

Bases: ThreadedService

Service that updates jurisdiction info into a file

Parameters:

Methods

acquire_resources()

Open thread pool and temp directory

call(*args, **kwargs)

Call the service

process(county, doc, seconds_elapsed[, ...])

Add usage from tracker to file

process_using_futures(fut, *args, **kwargs)

Process a call to the service

release_resources()

Shutdown thread pool and cleanup temp directory

Attributes

MAX_CONCURRENT_JOBS

Max number of concurrent job submissions.

can_process

True if file not currently being written to

name

Service name used to pull the correct queue object

property can_process#

True if file not currently being written to

Type:

bool

async process(county, doc, seconds_elapsed, usage_tracker=None)[source]#

Add usage from tracker to file

Any existing usage info in the file will remain unchanged EXCEPT for anything under the label of the input tracker, all of which will be replaced with info from the tracker itself.

Parameters:
  • county (compass.utilities.location.Location) – County to record.

  • doc (elm.web.document.Document) – Document containing meta information about the jurisdiction. Must have relevant processing keys in the attrs dict, otherwise the jurisdiction may not be recorded properly. If None, the jurisdiction is assumed not to have been found.

  • seconds_elapsed (int or float) – Total number of seconds it took to look for (and possibly parse) this document.

  • usage_tracker (compass.services.usage.UsageTracker, optional) – Optional tracker instance to monitor token usage during LLM calls. By default, None.

MAX_CONCURRENT_JOBS = 10000#

Max number of concurrent job submissions.

acquire_resources()#

Open thread pool and temp directory

async classmethod call(*args, **kwargs)#

Call the service

Parameters:

*args, **kwargs – Positional and keyword arguments to be passed to the underlying service processing function.

Returns:

obj – A response object from the underlying service.

property name#

Service name used to pull the correct queue object

Type:

str

async process_using_futures(fut, *args, **kwargs)#

Process a call to the service

Parameters:
  • fut (asyncio.Future) – A future object that should get the result of the processing operation. If the processing function returns answer, this method should call fut.set_result(answer).

  • **kwargs – Keyword arguments to be passed to the underlying processing function.

release_resources()#

Shutdown thread pool and cleanup temp directory