Skip to main content

No module named 'charset_normalizer.md__mypyc'

· One min read
  • report message
Traceback (most recent call last):
File "requests\compat.py", line 11, in <module>
ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "minarca_client\main.py", line 15, in <module>
from minarca_client.core import (
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "minarca_client\core\__init__.py", line 23, in <module>
import requests
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\__init__.py", line 45, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\exceptions.py", line 9, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "requests\compat.py", line 13, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\__init__.py", line 24, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\api.py", line 5, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "charset_normalizer\cd.py", line 9, in <module>
ModuleNotFoundError: No module named 'charset_normalizer.md__mypyc'
  • resolution
pyinstaller --hiddenimport charset_normalizer.md__mypyc

coredump related settings

· One min read

1. coredump limits

  • for this login time
ulimits -c unlimited
  • for the permanent time
vim /etc/security/limits.conf

* soft core unlimited
* hard core unlimited

2. coredump file path

sudo sysctl -w kernel.core_pattern="|/tmp/core_dump_example.py %e"

man core for the details about % part like %e in coredump file name

3. generating coredump

kill -SIGSEGV ${PID}

generate coredump for docker container

· One min read
  • use --cap-add=SYS_PTRACE flag when running the container
docker run --cap-add=SYS_PTRACE ...
  • add it to a docker-compose file
version: '3'
services:
your-service:
image: your-image
cap_add:
- SYS_PTRACE

yum error with SyntaxError: invalid syntax

· One min read

yum error message:

[root@31f24739f206 /]# yum File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax

  • change default python from python3 to python2
alternatives --install /usr/bin/python python /usr/bin/python2 0

Docker: Enable Non-Root User Access

· One min read

Enable Non-Root User Access

  1. Enter the command below to create the docker group on the system.
sudo groupadd -f docker
  1. Type the following usermod command to add the active user to the docker group.
sudo usermod -aG docker $USER
  1. Apply the group changes to the current terminal session by typing:
newgrp docker
  1. Check if the docker group is in the list of user groups.
groups

Why openldap doesn't sync from master

· 2 min read

config

#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#

...

# #开启同步
# overlay syncprov
# #contextCSN 当修改20条时 或者10分钟
# syncprov-checkpoint 20 10
# #session 每次同步数据最大量
# syncprov-sessionlog 1000

slave logs

Feb 17 10:08:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep1: rid=000 starting refresh (sending cookie=rid=000,csn=20230216083743.943082Z#000000#002#000000) Feb 17 10:08:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep2: rid=000 got search entry without Sync State control (dc=sinopec,dc=com) Feb 17 10:08:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrepl: rid=000 rc -1 retrying (9 retries left) Feb 17 10:09:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep1: rid=000 starting refresh (sending cookie=rid=000,csn=20230216083743.943082Z#000000#002#000000) Feb 17 10:09:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep2: rid=000 got search entry without Sync State control (dc=sinopec,dc=com) Feb 17 10:09:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrepl: rid=000 rc -1 retrying (8 retries left) Feb 17 10:10:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep1: rid=000 starting refresh (sending cookie=rid=000,csn=20230216083743.943082Z#000000#002#000000) Feb 17 10:10:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep2: rid=000 got search entry without Sync State control (dc=sinopec,dc=com) Feb 17 10:10:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrepl: rid=000 rc -1 retrying (7 retries left) Feb 17 10:11:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep1: rid=000 starting refresh (sending cookie=rid=000,csn=20230216083743.943082Z#000000#002#000000) Feb 17 10:11:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep2: rid=000 got search entry without Sync State control (dc=sinopec,dc=com) Feb 17 10:11:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrepl: rid=000 rc -1 retrying (6 retries left) Feb 17 10:12:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep1: rid=000 starting refresh (sending cookie=rid=000,csn=20230216083743.943082Z#000000#002#000000) Feb 17 10:12:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrep2: rid=000 got search entry without Sync State control (dc=sinopec,dc=com) Feb 17 10:12:20 host-10-213-115-95 bdl[pid=3007515,tid=0xeef7da40]: do_syncrepl: rid=000 rc -1 retrying (5 retries left)

Solutions

uncomment overlay syncprov on master

#开启同步
overlay syncprov
#contextCSN 当修改20条时 或者10分钟
syncprov-checkpoint 20 10
#session 每次同步数据最大量
syncprov-sessionlog 1000

Useful Macro that can be a template

· One min read
#define SYSCALL_DEFINE(name) static inline long SYSC_##name
#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)


/*
* Example
*/

/**
* sys_sched_setparam - set/change the RT priority of a thread
* @pid: the pid in question.
* @param: structure containing the new RT priority.
*/
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
{
return do_sched_setscheduler(pid, -1, param);
}

#define SYSCALL_DEFINE(name) static inline long SYSC_##name
#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)


/*
* Example
*/

/**
* sys_sched_setparam - set/change the RT priority of a thread
* @pid: the pid in question.
* @param: structure containing the new RT priority.
*/
SYSCALL_DEFINE2(sched_setparam, pid_t, pid, struct sched_param __user *, param)
{
return do_sched_setscheduler(pid, -1, param);
}