我正在寻找SOS的!SyncBlk命令生成的输出的描述.
特别是我没有找到关于"MonitorHeld"列的有用解释.此列显示一系列故障转储中的高值.
例:
0:000> !SyncBlk
Index SyncBlock MonitorHeld Recursion Owning Thread Info SyncBlock Owner
44 0000000005a5c228 1 1 000000000e7a6740 2304 273 000000019f858cd0 System.Object
48 000000000579bae8 1 1 000000000e7a72e0 2370 275 000000015f999900 System.Object
52 000000000579b9c8 1 1 0000000011bbd3b0 1e98 295 00000000ff89fe08 System.Object
54 000000000579b938 1 1 000000000e7a38c0 1be4 249 000000013f8aa888 System.Object
108 0000000005a5bfe8 1 1 000000000e79f300 224c 242 00000000ff8a5828 System.Object
110 0000000005a5c078 1 1 000000000e79ca50 2290 262 000000015f9a8020 System.Object
112 0000000005a5c108 1 1 0000000011bb70e0 1d38 236 000000015f99e408 System.Object
114 000000000579b620 1 …Run Code Online (Sandbox Code Playgroud) Did anyone experience or know of negative side effects from having a high service instance count like 60k? Aside from the memory consumption of course.
我计划在生产环境中增加允许的最大实例数的阈值.我基本上厌倦了严重的生产事件只是因为"某些东西"忘记了正确关闭代理.
我计划进行类似60k实例的操作,这将允许服务使用默认会话超时以我们客户的平均呼叫率生存.
限制设置将是:
谢谢,亚历克斯
如何添加可选且不得多次指定的参数?
有效的:
$ ./my.py
$ ./my.py --arg MyArgValue
Run Code Online (Sandbox Code Playgroud)
无效的:
$ ./my.py --arg MyArgValue --arg ThisIsNotValid
Run Code Online (Sandbox Code Playgroud)
如果我添加一个参数,如:
parser.add_argument('--arg', type=str)
Run Code Online (Sandbox Code Playgroud)
无效示例产生一个字符串ThisIsNotValid。我预计会出现解析器错误。
使用Autofac,我想注册一个组件并指定要解析为命名实例的特定依赖项.
我使用构造函数注入找到了类似下面的示例,这几乎是我想要的.
builder.Register(c => new ObjectContainer(ConnectionStrings.CustomerDB))
.As<IObjectContainer>()
.Named("CustomerObjectContainer");
builder.Register(c => new ObjectContainer(ConnectionStrings.FooDB))
.As<IObjectContainer>()
.Named("FooObjectContainer");
builder.Register(c => new CustomerRepository(
c.Resolve<IObjectContainer>("CustomerObjectContainer"));
builder.Register(c => new FooRepository(
c.Resolve<IObjectContainer>("FooObjectContainer"));
Run Code Online (Sandbox Code Playgroud)
但是,我需要使用属性注入,我不想指定所有依赖项.
就像是:
builder.Register<CustomerRepository>().With<IObjectContainer>("CustomerObjectContainer");
builder.Register<FooRepository>().With<IObjectContainer>("FooObjectContainer");
Run Code Online (Sandbox Code Playgroud)
所有未指定的依赖项的构建应该在未命名的实例中发生.
谢谢,亚历克斯
[丹尼尔克回答]
对于该类型的任何属性,按类型解析的重载.
public static IRegistrationBuilder<TLimit, TReflectionActivatorData, TStyle> WithDependency<TLimit, TReflectionActivatorData, TStyle, TProperty>(
this IRegistrationBuilder<TLimit, TReflectionActivatorData, TStyle> registration,
Func<IComponentContext, TProperty> valueProvider)
where TReflectionActivatorData : ReflectionActivatorData
{
return registration.WithProperty(new ResolvedParameter((p, c) =>
{
PropertyInfo prop;
return p.TryGetDeclaringProperty(out prop) &&
prop.PropertyType == typeof(TProperty);
},
(p, c) => valueProvider(c)));
}
Run Code Online (Sandbox Code Playgroud) 我使用以下代码来处理SIGINT事件。该代码将multiprocessing.event设置为“唤醒”正在等待的主线程。
import multiprocessing
import signal
class Class1(object):
_stop_event = multiprocessing.Event()
@staticmethod
def interrupt():
Class1._stop_event.set()
def wait(self):
print("Waiting for _stop_event")
if Class1._stop_event.wait(5):
print("_stop_event set.")
else:
print("Timed out.")
def stop(signum, frame):
print("Received SIG")
Class1.interrupt()
signal.signal(signal.SIGINT, stop)
c = Class1()
c.wait()
Run Code Online (Sandbox Code Playgroud)
没有任何信号,wait方法将在10秒后超时,并且该过程将按预期方式退出,并显示以下输出:
Waiting for _stop_event
Timed out.
Run Code Online (Sandbox Code Playgroud)
发送SIGINT信号时,将处理该信号,但event.wait方法不会立即或在超时后都不会返回。该过程永远不会退出。输出为:
Waiting for _stop_event
^CReceived SIG
Run Code Online (Sandbox Code Playgroud)
我可以继续发送SIGINT。该过程将不会退出,输出为:
Waiting for _stop_event
^CReceived SIG
^CReceived SIG
^CReceived SIG
^CReceived SIG
....
Run Code Online (Sandbox Code Playgroud)
如果将Class1.wait方法替换为event.is_set检查,一切都会按预期进行:
def wait(self):
print("Waiting for _stop_event")
while True:
if Class1._stop_event.is_set():
print("_stop_event set.")
break
Run Code Online (Sandbox Code Playgroud)
该过程退出,输出为:
Waiting …Run Code Online (Sandbox Code Playgroud) 我对Java世界还是比较陌生的,并且在几十个或多或少做同样事情的图书馆之间选择的美丽让我感到不知所措.
有了Jetty和CXF.我正在寻找一个内置支持各种传输和协议的Web服务堆栈.
我的印象是CXF是最近的项目,并且将成为新软件项目的首选.特别是在涉及各种不同协议和标准(如WS-*)的应用程序时.
您能否就这些框架之间的差异发表意见?
哪一个对不同的协议和标准有更广泛的支持?
您更喜欢哪一个设计,例如它们如何将应用程序逻辑中的传输,身份验证,授权,序列化方面隐藏起来?
任何一种答案都非常欢迎!
干杯,亚历克斯