# -*- coding: UTF-8 -*-
from flask import Flask, request
import json
import time
import re
import sys
import asyncio
from tornado.ioloop import IOLoop
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
import sqlalchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///database.db?check_same_thread=False')
Base = declarative_base()
class ClientLog(Base):
__tablename__ = 'clientlog'
log_id = Column(Integer, primary_key=True, autoincrement=True)
message = Column(String(512))
def __repr__(self):
return "A"
from sqlalchemy.ext.declarative import DeclarativeMeta
class AlchemyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj.__class__, DeclarativeMeta):
# an SQLAlchemy class
fields = {}
for field in [x for x in dir(obj) if not x.startswith('_') and x != 'metadata']:
data = obj.__getattribute__(field)
try:
json.dumps(data) # this will fail on non-encodable values, like other classes
fields[field] = data
except TypeError:
fields[field] = None
# a json-encodable dict
return fields
return json.JSONEncoder.default(self, obj)
Base.metadata.create_all(engine, checkfirst=True)
Session = sessionmaker(bind=engine)
session = Session()
app = Flask("app")
@app.route('/api', methods=['GET', 'POST'])
@app.route('/api/', methods=['GET', 'POST'])
def api1():
session.add(ClientLog(message="test"))
session.commit()
return "test"
def launch_server():
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(8080)
IOLoop.current().start()
launch_server()
在阿里云的 Windows 2019 模板下 100 并发就会崩溃退出,报错
Exception in thread Tornado selector:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1045, in _bootstrap_inner
self.run()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 982, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\tornado\platform\asyncio.py", line 574, in _run_select
rs, ws, xs = select.select(to_read, to_write, to_write)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many file descriptors in select()
但是我在 Windows 10 的电脑上测试并发没问题
之前测试换了另外一个对 Windows 更友好的 web framework (想不起来名字,找了半天没找到)可以是可以,但是估计它用了不止一个进程写 SQLite ,导致冲突无法提交更改
业务需求调用一个 Windows Only 的 pip 包 ,无法更换 Linux 服务器
要想继续同步 Outlook 帐户的联系人,只能下载中国区 Outlook 安卓应用,在 app 里将 Outlook 帐户联系人同步(导入)到安卓手机。但这样做也存在问题:
①Outlook 帐户里以姓、名分开录入的联系人,通过 Outlook.app 导入安卓手机后,“张一二(姓:张,名:一二)”变成了“一二 张”(在手机联系人列表里还是显示为“张一二”,但点进该联系人编辑界面就能看到显示为“一二 张”),导致无法用 T9 快速搜索联系人(搜索“张一二”还是能找到该联系人),应该是我这台华为手机没有单独的姓、名栏目导致的。
②无法像之前 Exchange 协议那样双向同步。导入到安卓手机的联系人虽然显示是在 Outlook 帐户下,但通过安卓手机对联系人进行的新增或修改都无法同步到 Outlook 帐户云端,也就无法与其他设备进行同步;以及,当 Outlook 帐户联系人出现变动时,也不会自动同步到安卓手机上,只能手动操作 Outlook 应用进行同步。
请问,在无法通过安卓手机自身系统登录 Outlook Exchange 帐户的情况下,还有什么办法能与 iPhone 双向同步联系人?(在 A 手机编辑的联系人信息能及时、自动同步到 B 手机)
Police are searching for two sisters in Aberdeen who were last seen three days ago.
Eliza and Henrietta Huszti, both 32 and who live in Aberdeen city centre, were last seen in Market Street at Victoria Bridge at about 02:12 GMT on Tuesday.
They then crossed the bridge and turned into a footpath next to the River Dee in the direction of Aberdeen Boat Club.
Police Scotland said they are carrying "extensive enquires" and searches to find the sisters, including the use of police dogs and the marine unit.
Both Eliza and Henrietta are described as being white, slim build with long, brown hair.
Police said the side of Victoria Bridge in the Torry area, where they were last seen, contained many commercial and industrial units and searches are ongoing there.
It added it was urging businesses in and around the South Esplanade and Menzies Road area to review CCTV footage recorded in the early hours of Tuesday and dashcam footage.
Ch Insp Darren Bruce said: "We are continuing to speak to people who know Eliza and Henrietta and we urge anyone who has seen them or who has any information regarding their whereabouts to please contact 101 quoting incident number 0735 of Tuesday, 7 January, 2025."
Commuters are being warned of icy roads and travel disruption, as temperatures plummeted again overnight across the UK.
Fresh weather warnings have been issued, with snow, ice and fog forecast across southern England, Wales, Northern Ireland and northern Scotland on Thursday.
It will be mainly dry elsewhere with winter sunshine, but temperatures could fall again to as low as -16C on Thursday night.
The cold snap has already brought heavy snowfall to some areas, and dozens of flood alerts and warnings are in place due to either heavy rain or melting snow.
On Wednesday the lowest temperature recorded was -8.4C (16F) in Shap, Cumbria, according to the Met Office.
It comes as an amber cold health alert remains in place for all of England until Sunday, meaning the forecast weather is expected to have significant impacts across health - including a rise in deaths.
The Met Office says travel disruption to road and rail services is likely on Thursday in areas covered by warnings, as well potential for accidents in icy places.
There are five warnings in place:
A yellow warning for snow and ice is in place for northern Scotland until midnight on Thursday
A yellow warning for ice has been issued until 10:30 across southern England and south-east Wales
Two yellow warnings for snow and ice are in force until 11:00 GMT - one across western Wales and north-west England, and south-west England; and another for Northern Ireland
A yellow warning for fog until 09:00 in Northern Ireland
On Wednesday snow caused some roads to close and motorists to be stationary for "long periods of time" in Devon and Cornwall, according to authorities there.
Gritters working into Thursday morning have been fitted with ploughs to clear routes in the area.
Car insurer RAC said it has seen the highest levels of demand for rescues in a three-day period since December 2022.
"Cold conditions will last until at least the weekend, so we urge drivers to remain vigilant of the risks posed by ice and, in some locations, snow," said RAC breakdown spokeswoman Alice Simpson.
National Rail have also advised passengers to check before they travel, as ice and snow can mean speed restrictions and line closures.
On Wednesday evening, poor weather was affecting Northern and Great Western Railway.
Buses are also replacing trains between Llandudno Junction and Blaenau Ffestiniog until Monday.
The wintry conditions have caused significant disruption across the UK since snow swept many parts of the country at the weekend.
Hundreds of schools were closed in England, Scotland and Northern Ireland, including schools in Yorkshire, Merseyside, the Midlands and Aberdeenshire.
The country has also been hit by widespread flooding in recent days. Currently there are 68 flood warnings - meaning flooding is expected - in England and three in Wales.
The weather is expected to be less cold over the weekend.
Mel Gibson has revealed his home has been destroyed in the Los Angeles wildfires while he was away recording Joe Rogan's podcast.
The Oscar-winning film star said his Malibu property was "completely toasted" and criticised California Governor Gavin Newsom over the crisis.
At least 10 people have died in the wildfires, which have burned down thousands of buildings and prompted the evacuation of tens of thousands of residents.
A host of celebrities have told how they have lost their properties, while officials have warned more high winds could further fan the flames of the wildfires.
Gibson said he felt "ill at ease" during his visit to Austin, Texas, to appear as a guest on The Joe Rogan Experience, because he knew his neighbourhood was "on fire".
"It's kind of devastating, it's emotional," Gibson said on NewsNation's Elizabeth Vargas Reports.
"I've been relieved from the burden of my stuff because it's all in cinders."
The Braveheart star said he had lived at his property for about 15 years and the homes of some of his neighbours had also "gone", including one belonging to actor Ed Harris.
Gibson said his family had followed an evacuation order and they were safe.
In the podcast with Rogan, Gibson criticised the California governor, saying Newsom claimed he was "going to take care of the forests" but "didn't do anything".
"I think all our tax dollars probably went for Gavin's hair gel," the actor said.
Los Angeles is facing the worst wildfires in its history, which have consumed 31,000 acres (12,500 hectares) of land and led to the evacuation of 180,000 people.
Five wildfires are still burning across the LA areas of Palisades, Eaton, Kenneth, Hurst and Lidia.
California fire chief David Acuna told Radio 4's Today programme that 10,000 structures are likely to have been destroyed. He also warned that winds over the coming days could lead to further destruction in the area.
Republican President-elect Donald Trump has called for Newsom, a Democrat, to resign over his handling of the crisis, saying "one of the best and most beautiful" parts of the US is "burning down to the ground".
Newsom has defended the response and said state authorities were "throwing everything at our disposal" to protect communities.
The governor's spokeswoman accused Trump of politicising the disaster and said Newsom was focused on protecting people and making sure firefighters have the resources they need.
US President Joe Biden said he had pledged extra federal resources to help California after "the most widespread, devastating fire" in the state's history.
Celebrities who have lost homes
Paris Hilton and Billy Crystal are among the celebrities whose homes have been destroyed in the wildfires.
Hilton, the hotel heiress and reality TV star, shared a video of the remains of her property on social media and said "the heartbreak is truly indescribable".
Allow Twitter content?
This article contains content provided by Twitter. We ask for your permission before anything is loaded, as they may be using cookies and other technologies. You may want to read
before accepting. To view this content choose ‘accept and continue’.
Actor Crystal said in a statement that he and his wife Janice were "heartbroken" by the loss of their Pacific Palisades home where they had lived since 1979.
TV host Ricki Lake said she had lost her "dream home", adding: "I grieve along with all of those suffering during this apocalyptic event."
The US Office star Rainn Wilson shared a video of his burnt-out home and said there was a "valuable lesson" to learn from the wildfires.
Actors Sir Anthony Hopkins, John Goodman, Anna Faris and Cary Elwes also reportedly lost their homes.
Meanwhile, actor Steve Guttenberg, a Pacific Palisades resident, helped to move parked cars to make way for fire engines.
"This is not a parking lot," he told KTLA. "I have friends up there and they can't evacuate."
The Duke and Duchess of Sussex, who live in California, are understood to have invited into their home friends and loved ones who had been forced to evacuate.
In a statement on their website, Harry and Meghan said: "If a friend, loved one, or pet has to evacuate, and you are able to offer them a safe haven in your home, please do."
The accused mastermind of the 9/11 terror attacks on the US will no longer plead guilty on Friday, after the US government moved to block plea deals reached last year from going ahead.
Khalid Sheikh Mohammed, often referred to as KSM, was due to deliver his pleas at a war court on the Guantanamo Bay naval base in south-eastern Cuba, where he has been held in a military prison for almost two decades.
Mohammed is Guantanamo's most notorious detainee and one of the last held at the base.
But a federal appeals court on Thursday evening halted the scheduled proceedings to consider requests from the government to abandon the plea deals for Mohammed and two co-defendants, which it said would cause "irreparable" harm to both it and the public.
A three-judge panel said the delay "should not be construed in any way as a ruling on the merits", but was aimed at giving the court time to receive a full briefing and hear arguments "on an expedited basis".
The delay means that the matter will now fall into the incoming Trump administration.
What was scheduled to happen this week?
At a hearing beginning on Friday morning, Mohammed was scheduled to plead guilty to his role in the 11 September 2001 attacks, when hijackers seized passenger planes and crashed them into the World Trade Center in New York and the Pentagon outside of Washington. Another plane crashed into a field in Pennsylvania after passengers fought back.
Mohammed has been charged with offences including conspiracy and murder, with 2,976 victims listed on the charge sheet.
He has previously said that he planned the "9/11 operation from A-to-Z" - conceiving the idea of training pilots to fly commercial planes into buildings and taking those plans to Osama bin Laden, leader of the militant Islamist group al-Qaeda, in the mid 1990s.
Friday's hearing was set to happen in a courtroom on the base, where family members of those killed and the press would have been seated in a viewing gallery behind thick glass.
Pre-trial hearings, held at a military court on the naval base, have been going on for more than a decade, complicated by questions over whether torture Mohammed and other defendants faced while in US custody taints the evidence.
Following his arrest in Pakistan in 2003, Mohammed spent three years at secret CIA prisons known as "black sites" where he was subjected to simulated drowning, or "waterboarding", 183 times, among other so-called "advanced interrogation techniques" that included sleep deprivation and forced nudity.
Karen Greenberg, author of The Least Worst Place: How Guantanamo Became the World's Most Notorious Prison, says the use of torture has made it "virtually impossible to bring these cases to trial in a way that honors the rule of law and American jurisprudence".
"It's apparently impossible to present evidence in these cases without the use of evidence derived from torture. Moreover, the fact that these individuals were tortured adds another level of complexity to the prosecutions," she says.
The case also falls under the military commissions, which operate under different rules than the traditional US criminal justice system and slow the process down.
The plea deal was struck last summer, following some two years of negotiations.
What does the plea deal include?
The full details of the deals reached with Mohammed and two of his co-defendants have not been released.
We do know that a deal means he would not face a death penalty trial.
In a court hearing on Wednesday, his legal team confirmed that he had agreed to plead guilty to all charges. Mohammed did not address the court personally, but engaged with his team as they went over the agreement, making small corrections and changes to wording with the prosecution and the judge.
If the deals are upheld and the pleas are accepted by the court, the next steps would be appointing a military jury, known as a panel, to hear evidence at a sentencing hearing.
In court on Wednesday, this was described by lawyers as a form of public trial, where survivors and family members of those killed would be given the opportunity to give statements.
Under the agreement, the families would also be able to pose questions to Mohammed, who would be required to "answer their questions fully and truthfully", lawyers say.
Central to the prosecution agreeing to the deals was a guarantee "that we could present all of the evidence that we thought was necessary to establish a historical record of the accused's involvement in what happened on September 11th," prosecutor, Clayton G. Trivett Jr., said in court on Wednesday.
Even if the pleas go ahead, it would be many months before these proceedings would begin and a sentence ultimately delivered.
Why is the US government trying to block the pleas?
US Defense Secretary Lloyd Austin appointed the senior official who signed the deal. But he was travelling at the time it was signed and was reportedly caught by surprise, according to the New York Times.
Days later, he attempted to revoke it, saying in a memo: "Responsibility for such a decision should rest with me as the superior authority."
However, both a military judge and a military appeals panel ruled that the deal was valid, and that Mr Austin had acted too late.
In another bid to block the deal, the government this week asked a federal appeals court to intervene.
In a legal filing, it said Mohammed and the two other men were charged with "perpetrating the most egregious criminal act on American soil in modern history" and that enforcing the agreements would "deprive the government and the American people of a public trial as to the respondents' guilt and the possibility of capital punishment, despite the fact that the Secretary of Defense has lawfully withdrawn those agreements".
Following the announcement of the deal last summer, Republican Senator Mitch McConnell, then the party's leader in the chamber, released a statement describing it as "a revolting abdication of the government's responsibility to defend America and provide justice".
What have the victims' families said?
Some families of those killed in the attacks have also criticised the deal, saying it is too lenient or lacks transparency.
Speaking to the BBC's Today Programme last summer, Terry Strada, whose husband Tom was killed in the attacks, described the deal as "giving the detainees in Guantanamo Bay what they want".
Ms Strada, the national chair of the campaign group 9/11 Families United, said: "This is a victory for Khalid Sheikh Mohammed and the other two, it's a victory for them."
Other families see the agreements as a path towards convictions in the complex and long-running proceedings and were disappointed by the government's latest intervention.
Stephan Gerhardt, whose younger brother Ralph was killed in the attacks, had flown to Guantanamo Bay to watch Mohammed plead guilty.
"What is the end goal for the Biden administration? So they get the stay and this drags into the next administration. To what end? Think about the families. Why are you prolonging this saga?" he said.
Mr Gerhardt told the BBC the deals were "not a victory" for the families, but that it was "time to find a way to close this, to convict these men".
Families on the base were meeting with the press when news of the delay was made public.
"It was supposed to be a time of healing. We'll board that plane still with that deep sense of pain – there's just no end to it," one said.
Why are the proceedings happening in Guantanamo?
Mohammed has been held in a military prison in Guantanamo Bay since 2006.
The prison was opened 23 years ago - on 11 January 2002 - during the "war on terror" that followed the 9/11 attacks, as a place to hold terror suspects and "illegal enemy combatants".
Most of those held here were never charged and the military prison has faced criticism from rights groups and the United Nations over its treatment of detainees. The majority have now been repatriated or resettled in other countries.
The prison currently holds 15 - the smallest number at any point in its history. All but six of them have been charged with or convicted of war crimes.