在 github 操作中,我正在运行一个尝试使用 github 到 GCP 联合 ID 的操作:
# see https://github.com/marketplace/actions/authenticate-to-google-cloud#setup
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v0'
with:
workload_identity_provider: 'projects/1234/locations/global/workloadIdentityPools/my-github-pool/providers/my-github-oidc-provider'
service_account: 'my-github-sa@projxyz.iam.gserviceaccount.com'
Run Code Online (Sandbox Code Playgroud)
我越来越:
Run google-github-actions/auth@v0
Error: google-github-actions/auth failed with: retry function failed after 1 attempt:
gitHub Actions did not inject $ACTIONS_ID_TOKEN_REQUEST_TOKEN or
$ACTIONS_ID_TOKEN_REQUEST_URL into this job.
This most likely means the GitHub Actions workflow permissions are incorrect, or this job is being run from a fork.
For more information, please see https://docs.github.com/en/actions/security-guides/automatic-
token-authentication#permissions-for-the-github_token
Run Code Online (Sandbox Code Playgroud)
我正在查看引用的文档,但没有看到任何有用的内容。
如何让 …
假设我在python3中有一个数据类。我希望能够哈希和排序这些对象。
我只希望它们在ID上排序/散列。
我在文档中看到,我可以只实现__hash__,但我想让datacalses为我完成工作,因为它们旨在处理此问题。
from dataclasses import dataclass, field
@dataclass(eq=True, order=True)
class Category:
id: str = field(compare=True)
name: str = field(default="set this in post_init", compare=False)
a = sorted(list(set([ Category(id='x'), Category(id='y')])))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'Category'
Run Code Online (Sandbox Code Playgroud) 我试图在akka Actors中获得容错行为.我正在研究一些代码,这些代码依赖于系统中的Actors可用于长时间的处理.我发现我的处理在几个小时后停止(它应该需要大约10个小时)并且没有太多事情发生.我相信我的演员没有从异常中恢复过来.
我需要做什么才能永久地一对一地重新启动Actors?我希望这可以通过这份文件来完成http://akka.io/docs/akka/1.1.3/scala/fault-tolerance
我正在使用akka 1.1.3和scala 2.9
import akka.actor.Actor
import akka.actor.Actor._
import akka.actor.ActorRef
import akka.actor.MaximumNumberOfRestartsWithinTimeRangeReached
import akka.dispatch.Dispatchers
import akka.routing.CyclicIterator
import akka.routing.LoadBalancer
import akka.config.Supervision._
object TestActor {
val dispatcher = Dispatchers.newExecutorBasedEventDrivenWorkStealingDispatcher("pool")
.setCorePoolSize(100)
.setMaxPoolSize(100)
.build
}
class TestActor(val name: Integer) extends Actor {
self.lifeCycle = Permanent
self.dispatcher = TestActor.dispatcher
def receive = {
case num: Integer => {
if( num % 2 == 0 )
throw new Exception("This is a simulated failure")
println("Actor: " + name + " Received: " + num) …
Run Code Online (Sandbox Code Playgroud) 我想将 sqlalchemy 池大小设置为默认值以外的值。
我有一个烧瓶应用程序。我使用 app.config.from_pyfile('config.py') 从文件文件设置配置
在初始化数据库之前,我已经转储了配置,其中包括:
'SQLALCHEMY_DATABASE_URI': 'mysql://readonly:password@localhost/xyz',
'SQLALCHEMY_ECHO': False,
'SQLALCHEMY_MAX_OVERFLOW': 0,
'SQLALCHEMY_POOL_SIZE': 1,
'SQLALCHEMY_RECORD_QUERIES': False,
'SQLALCHEMY_TRACK_MODIFICATIONS': False,
Run Code Online (Sandbox Code Playgroud)
加载配置并执行转储后,我们立即调用一些代码,例如:
db: SQLAlchemy = SQLAlchemy()
db.init_app(app)
Run Code Online (Sandbox Code Playgroud)
我在 apache 上使用 mod_python 运行这个程序,其中有一个进程和一个线程。我在 httpd.conf 中使用它
WSGIDaemonProcess browse user=busybody group=busybody processes=1 threads=1 lang='en_US.UTF-8' locale='en_US.UTF-8' python-home=/users/x/virtualenvs/browse-wfalcMKM home=/users/x/browse
WSGIScriptAlias /abs /users/e-prints/browse/wsgi.py/abs
Run Code Online (Sandbox Code Playgroud)
然后我用 siege 和 100 个并发连接来锤炼这个。
我在 mysql SHOW PROCESSLIST 中为用户“readonly”获取了 20 个进程;我期望在显示进程列表中看到用户“只读”的 1 个进程;
没有其他应用程序使用用户“只读”,当我停止 httpd/python/flask 应用程序时,显示进程列表中有零个“只读”用户;
我希望按照我在此处的文档中尝试的方式配置事物:http://flask-sqlalchemy.pocoo.org/2.3/config/
我正在使用 python 3.6 和 mysql 5.1.73。看来我有 Flask_SQLAlchemy 2.3.2、mysqlclient 1.3.13 和 SQLAlchemy 1.2.12。这是在linux上的。Apache 与 mod-wsgi 4.5.15。
更新: …
我试图使用MySQLdb驱动程序将一些阿拉伯语单词插入arabic_word
我的hanswehr2
数据库Maria DB 的列中.
我得到了一个latin-1 encode error
.但在阅读之后,我发现MySQLdb驱动程序是默认的latin-1
,我必须在函数中明确设置utf-8
为我的选择字符集mariadb.connect()
.酱.
整个数据库设置为utf-8.
码:
def insert_into_db(arabic_word, definition):
try:
conn = mariadb.connect('localhost', 'root', 'xyz1234passwd', 'hans_wehr', charset='utf-8', use_unicode=True)
conn.autocommit(True)
cur = conn.cursor()
cur.execute("INSERT INTO hanswehr2 (arabic_word , definition) VALUES (%s,%s)", (arabic_word, definition,))
except mariadb.Error, e:
print e
sys.exit(1)
Run Code Online (Sandbox Code Playgroud)
但是现在我收到以下错误:
/usr/bin/python2.7 /home/heisenberg/hans_wehr/main.py
Total lines 87672
(2019, "Can't initialize character set utf-8 (path: /usr/share/mysql/charsets/)")
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我已经指定Python MySQL驱动程序使用utf-8字符,但它似乎忽略了这一点.
任何投入都将受到高度赞赏.
我正在尝试用 SQLAlchemy 1.4 异步替换数据库。当我尝试制作引擎时,出现以下错误:
sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'mysqldb' is not async.
我正在制作这样的引擎:
engine = create_async_engine(SQLALCHEMY_DATABASE_URL, future=True)
Run Code Online (Sandbox Code Playgroud)
需要什么才能让 mysqldb 与 SQLAlchemy 异步工作?
python ×4
python-3.x ×3
sqlalchemy ×2
actor ×1
akka ×1
flask ×1
hash ×1
iso-8859-1 ×1
mysql ×1
scala ×1
utf-8 ×1