Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.10 #439

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
default: true
description: Set to false to disable pushing image
machine:
image: ubuntu-2004:202101-01
image: ubuntu-2204:current
resource_class: <<parameters.resource_class>>
working_directory: ~/sync-engine

Expand Down Expand Up @@ -150,8 +150,8 @@ jobs:
PROJECT_SHA="$CIRCLE_SHA1"
docker login -u $DOCKER_USER -p $DOCKER_PASS
# tag and push both sync-engine:master and sync-engine:<sha1>
docker tag "${PROJECT}_app" "${PROJECT_NAMESPACE}/${PROJECT}:branch-${PROJECT_VSN}<< parameters.platform_suffix >>"
docker tag "${PROJECT}_app" "${PROJECT_NAMESPACE}/${PROJECT}:${PROJECT_SHA}<< parameters.platform_suffix >>"
docker tag "${PROJECT}-app" "${PROJECT_NAMESPACE}/${PROJECT}:branch-${PROJECT_VSN}<< parameters.platform_suffix >>"
docker tag "${PROJECT}-app" "${PROJECT_NAMESPACE}/${PROJECT}:${PROJECT_SHA}<< parameters.platform_suffix >>"
docker push "${PROJECT_NAMESPACE}/${PROJECT}:branch-${PROJECT_VSN}<< parameters.platform_suffix >>"
docker push "${PROJECT_NAMESPACE}/${PROJECT}:${PROJECT_SHA}<< parameters.platform_suffix >>"

Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

RUN groupadd -g 5000 sync-engine \
&& useradd -d /home/sync-engine -m -u 5000 -g 5000 sync-engine
Expand All @@ -23,7 +23,8 @@ RUN echo $BUILD_WEEK && apt-get update \
gettext-base \
language-pack-en \
libcurl4-openssl-dev \
libmysqlclient-dev \
# libmysqlclient-dev \
libmariadb-dev-compat \
libxml2-dev \
libxslt-dev \
libxslt1-dev \
Expand Down
17 changes: 11 additions & 6 deletions inbox/ignition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import gevent
import limitlion
import MySQLdb
import redis
from sqlalchemy import create_engine, event

Expand Down Expand Up @@ -62,6 +63,15 @@ def engine(
pool_timeout=DB_POOL_TIMEOUT,
echo=False,
):
connect_args = {
"binary_prefix": True,
"charset": "utf8mb4",
"connect_timeout": 60,
}

if MySQLdb.version_info < (1, 4):
connect_args["waiter"] = gevent_waiter

engine = create_engine(
database_uri,
poolclass=ForceStrictModePool,
Expand All @@ -71,12 +81,7 @@ def engine(
pool_timeout=pool_timeout,
pool_recycle=3600,
max_overflow=max_overflow,
connect_args={
"binary_prefix": True,
"charset": "utf8mb4",
"waiter": gevent_waiter,
"connect_timeout": 60,
},
connect_args=connect_args,
)

@event.listens_for(engine, "checkout")
Expand Down
5 changes: 4 additions & 1 deletion inbox/util/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import ssl
import sys

import _mysql_exceptions
try:
import _mysql_exceptions
except ImportError:
import MySQLdb._exceptions as _mysql_exceptions
import gevent
from gevent import socket
from redis import TimeoutError
Expand Down
9 changes: 8 additions & 1 deletion inbox/util/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ def strip_tags(html: str) -> str:
You are responsible for handling it in the calling function.
"""
s = HTMLTagStripper()
s.feed(html)

try:
s.feed(html)
except AssertionError as e:
if e.args[0].startswith("unknown status keyword"):
raise HTMLParseError(*e.args) from e
raise

return s.get_data()


Expand Down
5 changes: 3 additions & 2 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ Jinja2==2.11.3
jmespath==0.9.3
limitlion==0.10.0
lxml==4.9.1
--no-binary lxml
# --no-binary lxml
Mako==1.2.2
MarkupSafe==1.1.1
matplotlib-inline==0.1.3
mysqlclient==1.3.14
mysqlclient==1.3.14; python_version < '3.10'
git+https://github.com/axiros/gevent_mysqldb.git; python_version >= '3.10'
parso==0.8.2
pexpect==4.8.0
pickleshare==0.7.5
Expand Down
6 changes: 5 additions & 1 deletion tests/general/test_concurrency.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import time

import _mysql_exceptions
try:
import _mysql_exceptions
except ImportError:
import MySQLdb._exceptions as _mysql_exceptions

import pytest
from gevent import GreenletExit, socket
from sqlalchemy.exc import StatementError
Expand Down