Closing a Screen Session from Outside the Session

Screen is an excellent tool for running programs in the background. Typically, you can connect to a session using screen -r and then close the session with Ctrl + C. However, if you’ve implemented exception handling (like try-except) in your Python scripts, you’ll find that this only breaks out of the loop and doesn’t terminate the entire session. In such cases, directly closing a specific session from outside the session is much more convenient.

The command to do this is:

screen -XS test quit

Here, test is the name of your session. Of course, to view all active sessions, you can use:

screen -ls

Here’s an example sequence of commands:

screen -S test python test.py
screen -ls
screen -XS test quit
screen -ls

screen_test

……

阅读全文

screen session外关闭session会话

screen作为一个用来后台运行的程序非常好用,一般情况下screen -r连接到会话使用ctr + c就可以关闭会话了,但是像我这样在python脚本里面使用了try except捕获异常的话就会发现根本关闭不了整个会话,而仅仅是跳出了循环而已,所以在会话外直接关闭特定会话就比较方便,

其实命令就是

……

阅读全文

thunder迅雷下载地址真实地址解析

经常下载视频游戏之类的同学们应该经常碰到thunder开头的迅雷下载地址,但是却经常由于版权问题不能下载,那么这里就普通下载url与迅雷下载地址转换进行说明……

阅读全文

Running Conda Command-Line Scripts on Windows

I needed to remotely update website content from my Windows machine at home, and while I have Conda installed on Windows, I found I couldn’t directly write and run scripts. I could only launch Conda from the Start menu and type commands line by line.

After some searching and learning, I finally found a solution.

The reason you can’t directly write and run .bat batch files for Conda commands (which use various Python libraries from Conda) is that the default cmd.exe doesn’t activate the Conda environment. Once you add the environment activation command, your scripts will run. You can refer to the original English explanation here: https://stackoverflow.com/questions/46305569/how-to-make-batch-files-run-in-anaconda-prompt.

The final command structure looks like this:

call 'G:/conda/Scripts/activate.bat' 
scrapy crawl dou
python tupian.py
python post.py
……

阅读全文

windows下运行conda命令行脚本

由于在家需要使用windows远程更新网站内容,windows上也安装了conda,但是发现无法在windows下直接写下脚本运行,只能从启动项里面找到conda运行后一行一行输入才行。

通过搜索学习,最终找到解决办法。

首先为什么无法直接写好bat批处理文件来运行, 命令使用到conda的各种python库,这是因为系统默认的cmd.exe并没有激活conda环境,在加入环境激活命令后就可以运行了。参考链接https://stackoverflow.com/questions/46305569/how-to-make-batch-files-run-in-anaconda-prompt, 可看英文原版解释。

……

阅读全文

Accelerating Python Code with Numba to C++-like Speeds

1. Introduction

Numba is a Just-in-Time (JIT) compiler for Python. This means that when you call a Python function, all or part of your code is converted “on-the-fly” into machine code, which then runs at the speed of your native machine! It is sponsored by Anaconda, Inc. and supported by many other organizations.

With Numba’s help, you can accelerate all computationally intensive Python functions (e.g., loops). It also supports the NumPy library! So, you can use NumPy in your computations and speed up overall calculations, as loops in Python are notoriously slow. You can also use many functions from Python’s standard math library, such as sqrt, etc.


2. Why Choose Numba?

《Accelerating Python Code with Numba to C++-like Speeds》

So, why choose Numba when there are many other compilers like Cython and PyPy? The reason is simple: you don’t have to leave the comfort zone of writing Python code. That’s right, you don’t need to change your code at all to get a speedup comparable to what you’d get from similar type-defined Cython code. Isn’t that great?

……

阅读全文

用 Numba 加速 Python 代码,变得像 C++ 一样快

1. 介绍

Numba 是 python 的即时(Just-in-time)编译器,即当您调用 python 函数时,您的全部或部分代码就会被转换为“即时”执行的机器码,它将以您的本地机器码速度运行!它由 Anaconda 公司赞助,并得到了许多其他组织的支持。

在 Numba 的帮助下,您可以加速所有计算负载比较大的 python 函数(例如循环)。它还支持 numpy 库!所以,您也可以在您的计算中使用 numpy,并加快整体计算,因为 python 中的循环非常慢。 您还可以使用 python 标准库中的 math 库的许多函数,如 sqrt等。

……

阅读全文

最近文章

分类

标签

友情链接

其它