Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Matrix
Merge requests
!21
Draft: Resolve "Introduce logging"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Draft: Resolve "Introduce logging"
23-introduce-logging
into
master
Overview
0
Commits
1
Pipelines
2
Changes
2
Open
Jonathan Weth
requested to merge
23-introduce-logging
into
master
2 years ago
Overview
0
Commits
1
Pipelines
2
Changes
2
Expand
Closes
#23
0
0
Merge request reports
Compare
master
master (HEAD)
and
latest version
latest version
8f528bea
1 commit,
2 years ago
2 files
+
28
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
aleksis/apps/matrix/util/matrix.py
+
6
−
1
Options
import
logging
import
time
from
json
import
JSONDecodeError
from
typing
import
Any
,
Optional
@@ -28,6 +29,7 @@ def get_headers() -> dict[str, str]:
def
do_matrix_request
(
method
:
str
,
url
:
str
,
body
:
Optional
[
dict
]
=
None
)
->
dict
[
str
,
Any
]:
"""
Do a HTTP request to the Matrix Client Server API.
"""
logging
.
debug
(
f
"
Matrix request:
{
method
}
{
url
}
{
body
}
"
)
while
True
:
res
=
requests
.
request
(
method
=
method
,
url
=
build_url
(
url
),
headers
=
get_headers
(),
json
=
body
)
# noqa: S113
@@ -41,8 +43,11 @@ def do_matrix_request(method: str, url: str, body: Optional[dict] = None) -> dic
# If rate limit exceeded, wait and retry
if
data
.
get
(
"
errcode
"
,
""
)
==
"
M_LIMIT_EXCEEDED
"
:
time
.
sleep
(
data
[
"
retry_after_ms
"
]
/
1000
)
wait_time
=
data
[
"
retry_after_ms
"
]
/
1000
logging
.
debug
(
f
"
Rate limit exceeded, waiting
{
wait_time
}
seconds
"
)
time
.
sleep
(
wait_time
)
else
:
logging
.
error
(
f
"
Matrix request failed:
{
data
}
"
)
raise
MatrixException
(
data
)
return
data
Loading