clips / clips/pattern

plaintext is not threadsafe

Open
#118 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

The plaintext function (https://github.com/clips/pattern/blob/master/pattern/web/__init__.py#L969)
Is not threadsafe as it's reusing HTMLTagstripper().strip.

It happens very rarely but scenario is as follows:

Right now I rewrote the plaintext function to instatiate HTMLTagstripper every time, but
it would be amazing if there was a better way to make the plaintext function threadsafe.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read pattern/web/init.py at plaintext around line 969 and HTMLTagstripper.strip around line 810, then trace how the shared _data attribute is populated. Confirm concurrent calls cannot mix their output; the issue is done when each plaintext call returns only its own complete text.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.