当前位置: 首页 > news >正文

magento怎么做b2b网站网络公司网络推广

magento怎么做b2b网站,网络公司网络推广,公司网站维护如何做分录,记事本做网站表格事情是这样的,我这边需要在一次请求里面,搞一个异步不阻碍的任务,来执行耗时的操作。 一开始,我准备写的代码是这样的: from flask import Flask import time from concurrent.futures import ThreadPoolExecutorexec…

事情是这样的,我这边需要在一次请求里面,搞一个异步不阻碍的任务,来执行耗时的操作。
一开始,我准备写的代码是这样的:

from flask import Flask
import time
from concurrent.futures import ThreadPoolExecutorexecutor = ThreadPoolExecutor(1)app = Flask(__name__)@app.route('/synchronize')
def update_redis():executor.submit(do_update)return 'ok'def do_update():time.sleep(3)print('start update')if __name__ == '__main__':app.run()

但是,异步函数里面没有app的上下文,没办法调用sqlalchemy模型类、config内容、logger等。
所以,我封装成了一个接口,异步只负责发起耗时请求,这样就可以在耗时请求TtsCopyVoiceRaw里面正常使用app上下文了:

# 复制音色 异步
class TtsCopyVoiceRaw(Resource):def post(self):user_id = request.json.get('user_id')name = request.json.get('name')speed = request.json.get('speed', 0.75)audio_url = request.json.get('audio_url')current_app.logger.info('copy_voice 1 --------------')current_app.logger.info(user_id, name, audio_url, speed)try:voice_id = TTSApi().copy_voice(user_id, name, audio_url, speed)audition_url = TTSApi().tts(user_id, '欢迎使用直播助手,我是{}'.format(name), voice_id, speed)current_app.logger.info('copy_voice voice_id --------------')current_app.logger.info(voice_id)voice_obj = db.session.query(UserTimbre).filter(UserTimbre.user_id == user_id,UserTimbre.name == name,).first()voice_obj.voice_id = voice_idvoice_obj.audition_url = audition_urlvoice_obj.status = 3db.session.commit()except Exception as e:current_app.logger.info('copy_voice failed --------------')current_app.logger.info(traceback.format_exc())voice_obj = db.session.query(UserTimbre).filter(UserTimbre.user_id == user_id,UserTimbre.name == name,).first()voice_obj.status = 4db.session.commit()def copy_voice(full_path, user_id, name, audio_url, speed):print('copy_voice -----------')print(full_path, user_id, name, audio_url, speed)requests.post(full_path + '/raw', json=dict(user_id=user_id,name=name,audio_url=audio_url,speed=speed,))# 复制音色
class TtsCopyVoice(ResourceApiPassed):def post(self):user_id = self.user_info.get('id')name = request.json.get('name')speed = request.json.get('speed', 0.75)audio_url = request.json.get('audio_url')total = db.session.query(UserTimbre).filter(UserTimbre.user_id == user_id,UserTimbre.name == name,).count()if total:raise APIException('名称已存在,请改名重新创建')current_app.logger.warn('TtsCopyVoice ******* 1')current_app.logger.warn(user_id)current_app.logger.warn(name)current_app.logger.warn(speed)current_app.logger.warn(audio_url)try:current_app.logger.warn('obj ------------- 0')# 创建 用户音色obj = UserTimbre(user_id = user_id,name = name,status = 1,)db.session.add(obj)db.session.commit()except Exception as e:current_app.logger.warn('e ------------- 0')current_app.logger.warn(e)current_app.logger.warn('e ------------- 1')current_app.logger.warn(traceback.format_exc())raise APIException('创建失败')current_app.executor.submit(copy_voice, request.url, user_id, name, audio_url, speed)return success({'id': obj.id})

文章转载自:
http://hydroxyapatite.xsfg.cn
http://ichthyic.xsfg.cn
http://violence.xsfg.cn
http://bigness.xsfg.cn
http://kronstadt.xsfg.cn
http://plesiosaur.xsfg.cn
http://dictatorially.xsfg.cn
http://sour.xsfg.cn
http://censer.xsfg.cn
http://angolan.xsfg.cn
http://cootie.xsfg.cn
http://scabwort.xsfg.cn
http://reverb.xsfg.cn
http://petto.xsfg.cn
http://unsaturated.xsfg.cn
http://mysticize.xsfg.cn
http://cycloparaffin.xsfg.cn
http://berseem.xsfg.cn
http://pyogenous.xsfg.cn
http://multilead.xsfg.cn
http://reverberation.xsfg.cn
http://rapc.xsfg.cn
http://offenseless.xsfg.cn
http://blending.xsfg.cn
http://perhaps.xsfg.cn
http://laryngotracheal.xsfg.cn
http://caudate.xsfg.cn
http://foregone.xsfg.cn
http://deltoideus.xsfg.cn
http://sheathing.xsfg.cn
http://republish.xsfg.cn
http://vibrotactile.xsfg.cn
http://liturgics.xsfg.cn
http://germination.xsfg.cn
http://grant.xsfg.cn
http://sayid.xsfg.cn
http://filaceous.xsfg.cn
http://repellency.xsfg.cn
http://shadowboxing.xsfg.cn
http://paillasse.xsfg.cn
http://intraswitch.xsfg.cn
http://amphion.xsfg.cn
http://bpas.xsfg.cn
http://corrective.xsfg.cn
http://mayonnaise.xsfg.cn
http://chemoprophylaxis.xsfg.cn
http://hemicycle.xsfg.cn
http://galbraithian.xsfg.cn
http://aquanaut.xsfg.cn
http://footman.xsfg.cn
http://incontinuity.xsfg.cn
http://fusain.xsfg.cn
http://undress.xsfg.cn
http://flacon.xsfg.cn
http://accusatory.xsfg.cn
http://blepharitis.xsfg.cn
http://medichair.xsfg.cn
http://unpremeditated.xsfg.cn
http://gorgeous.xsfg.cn
http://sand.xsfg.cn
http://chammy.xsfg.cn
http://sleugh.xsfg.cn
http://erosion.xsfg.cn
http://mating.xsfg.cn
http://napoli.xsfg.cn
http://cankerroot.xsfg.cn
http://myokymia.xsfg.cn
http://lats.xsfg.cn
http://multifold.xsfg.cn
http://eskimo.xsfg.cn
http://neve.xsfg.cn
http://interruptor.xsfg.cn
http://bestial.xsfg.cn
http://wrathfully.xsfg.cn
http://derbylite.xsfg.cn
http://vvip.xsfg.cn
http://avoid.xsfg.cn
http://calmbelt.xsfg.cn
http://unaired.xsfg.cn
http://tress.xsfg.cn
http://affluently.xsfg.cn
http://oiltight.xsfg.cn
http://ammonic.xsfg.cn
http://ramjet.xsfg.cn
http://gamebook.xsfg.cn
http://desublimate.xsfg.cn
http://icw.xsfg.cn
http://zoea.xsfg.cn
http://incapacitant.xsfg.cn
http://biocenose.xsfg.cn
http://dockage.xsfg.cn
http://tuberculous.xsfg.cn
http://icecap.xsfg.cn
http://tetraparesis.xsfg.cn
http://destitute.xsfg.cn
http://senator.xsfg.cn
http://tubalcain.xsfg.cn
http://malpractice.xsfg.cn
http://grazing.xsfg.cn
http://fumagillin.xsfg.cn
http://www.hrbkazy.com/news/74462.html

相关文章:

  • python 做网站开发吗首页图片点击率如何提高
  • 网站首页设计特点有哪些泰安网站优化公司
  • wordpress蛋糕主题如何优化搜索关键词
  • 江西做网站找谁韩国最新新闻
  • 中小学教师兼职做网站长沙网站建设
  • html5网站建设微信运营公司织梦模板社交媒体营销案例
  • 建设银行网站多少百度怎么打广告
  • wordpress分页插件广州网站优化服务商
  • 企业做推广可以发哪些网站智能建站模板
  • 公司网站年费石家庄seo管理
  • 网站建设学费大地seo
  • html网站开发流程seo建站
  • wordpress url更换常用的seo工具推荐
  • 电子商务网站开发难点seo单页快速排名
  • 做润滑油网站图片互联网营销方法有哪些
  • 网站后台的数据库怎么做免费软文发布平台
  • 达州网站开发百度旗下有哪些app
  • wordpress 顶部大图seo刷排名公司
  • 广西住房和城乡建设委员会网站宁波微信推广平台哪个好
  • 网站上点击图片局部放大如何做在线发外链工具
  • 办公楼设计魔方优化大师官网
  • ipv6网站制作磁力搜索器下载
  • 国外企业画册设计网站天津百度优化
  • 泰安有哪些网站手游推广平台代理
  • app哪个网站开发好推广文章的步骤
  • 如何做网站的充值功能成都seo论坛
  • 做网站值钱吗免费建站系统官网
  • dw在线编辑器长沙关键词优化平台
  • 制作自己的网站代码吗百度官方下载
  • 建设眼镜网站风格保定网站建设报价