Open lihailong00 opened 1 week ago
I am getting the same error:
Error: Only part of a ReadProcessMemory or WriteProcessMemory request was completed. (os error 299)
Reason: Only part of a ReadProcessMemory or WriteProcessMemory request was completed. (os error 299)
python 3.12 Windows 10 py-spy 0.4.0
Here's my code, function find_urls_from_text
is stuck in an endless loop. I use os.getpid()
to get the current process number. Then I execute py-spy record -o profile.svg --pid
in my terminal. then I am getting the error:
Error: Only part of a ReadProcessMemory or WriteProcessMemory request was completed. (os error 299)
Reason: Only part of a ReadProcessMemory or WriteProcessMemory request was completed. (os error 299)
import os
import re
from typing import List
def find_urls_from_text(text: str) -> List[str]:
"""
get websites from urls
:param text:
:return:
"""
url_pattern = (
r'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))'
)
# 查找所有匹配项
urls = re.findall(url_pattern, text, re.IGNORECASE)
# 提取完整的网址
cleaned_urls = [''.join(match[0].split()) for match in urls]
return cleaned_urls
print(os.getpid())
s = '中国政府采购网(http://www.ccgp.gov.cn)、广西壮族自治区政府采购网(http://zfcg.gxzf.gov.cn)、广西壮族自治区招标投标公共服务平台(http://zbtb.gxi.gov.cn:9000/)、全国公共资源交易平台(广西·百色)+(http://ggzy.jg+swj.gxzf.gov.cn/bsggzy/)、广西百色市住房和城乡建设局(http://zjj.baise.gov.cn)上发布'
res = find_urls_from_text(s)
print(res)
Same here. It's because of Python version. Py-spy doesn't support python 3.12 or 3.13 for sure yet. I can confirm that it works for Python 3.5. Also you can see Python 3.6 example in README.md file. But I don't know what is the maximum python version supported.
This error may be Windows only.
I agree the reason for the issue is python 3.12. I have been able to use py-spy fine on Windows with python 3.10. However, py-spy seems to be currently claiming to have python 3.12 and 3.13 support (See 0.4.0 release notes https://github.com/benfred/py-spy/releases/tag/v0.4.0). Such support many be Linux / MacOS only. If that is the case it should be clearly stated to users.
My Python version is 3.12.7 I use Windows 11 I run a python program in pycharm:
then print the process id: 58396
then I input "py-spy top --pid 58396" then Error occured:
What's the promblems.
Thanks for your reply~